Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Aug 6, 2023
1 parent ff7af13 commit 150741a
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@ describe("FlagRouter", function () {
expect(isEnabled).toEqual(true)
})

it("should check if nested flag is enabled using top-level access", async function () {
const flagRouter = new FlagRouter({
[workflows.key]: {
createCart: true,
},
})

const isEnabled = flagRouter.isFeatureEnabled("workflows")

expect(isEnabled).toEqual(true)
})

it("should return false if nested flag is disabled using top-level access", async function () {
const flagRouter = new FlagRouter({
[workflows.key]: false
})

const isEnabled = flagRouter.isFeatureEnabled("workflows")

expect(isEnabled).toEqual(false)
})

it("should return false if nested flag is disabled", async function () {
const flagRouter = new FlagRouter({
[workflows.key]: {
createCart: false,
}
})

const isEnabled = flagRouter.isFeatureEnabled({workflows: "createCart"})

expect(isEnabled).toEqual(false)
})

it("should initialize with both types of flags", async function () {
const flagRouter = new FlagRouter({
[workflows.key]: {
Expand Down

0 comments on commit 150741a

Please sign in to comment.