-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { axe } from "jest-axe"; | ||
import Index from "src/pages/index"; | ||
import { GetServerSidePropsContext } from "next"; | ||
import Index, { getServerSideProps } from "src/pages/index"; | ||
import { LocalFeatureFlagManager } from "src/services/feature-flags/LocalFeatureFlagManager"; | ||
import { render, screen } from "tests/react-utils"; | ||
|
||
describe("Index", () => { | ||
|
@@ -25,4 +27,17 @@ describe("Index", () => { | |
const { container } = render(<Index isFooEnabled={true} />); | ||
expect(container).toHaveTextContent("Flag is enabled"); | ||
}); | ||
|
||
it("retrieves feature flags", async () => { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
sawyerh
Contributor
|
||
const featureName = "foo"; | ||
const userId = "anonymous"; | ||
const featureFlagSpy = jest | ||
.spyOn(LocalFeatureFlagManager.prototype, "isFeatureEnabled") | ||
.mockResolvedValue(true); | ||
await getServerSideProps({ | ||
req: { cookies: {} }, | ||
res: {}, | ||
} as unknown as GetServerSidePropsContext); | ||
expect(featureFlagSpy).toHaveBeenCalledWith(featureName, userId); | ||
}); | ||
}); |
@aligg couple of thoughts on this test: