-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor unleash service and add some mocking
- Loading branch information
Showing
11 changed files
with
145 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,63 @@ | ||
import { afterAll, expect, test } from "bun:test"; | ||
import renderIndex from "./render-index"; | ||
import UnleashService from "./unleash-service"; | ||
import { http, HttpResponse } from "msw"; | ||
import { env } from "./env/server"; | ||
import { | ||
afterAll, | ||
afterEach, | ||
beforeAll, | ||
beforeEach, | ||
expect, | ||
test, | ||
describe, | ||
} from "bun:test"; | ||
import { clearCache } from "decorator-shared/cache"; | ||
import { HttpResponse, http } from "msw"; | ||
import { SetupServerApi, setupServer } from "msw/node"; | ||
import testData from "./content-test-data.json"; | ||
import { setupServer } from "msw/node"; | ||
|
||
const unleashService = new UnleashService({ mock: true }); | ||
import { env } from "./env/server"; | ||
import renderIndex from "./render-index"; | ||
|
||
test("It masks the document from hotjar", async () => { | ||
const server = setupServer( | ||
http.get(`${env.ENONICXP_SERVICES}/no.nav.navno/menu`, () => | ||
HttpResponse.json(testData), | ||
), | ||
); | ||
server.listen(); | ||
describe("render-index", () => { | ||
let server: SetupServerApi; | ||
|
||
beforeAll(() => { | ||
server = setupServer( | ||
http.get(`${env.ENONICXP_SERVICES}/no.nav.navno/menu`, () => | ||
HttpResponse.json(testData), | ||
), | ||
); | ||
server.listen(); | ||
}); | ||
beforeEach(() => clearCache()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
expect( | ||
await renderIndex({ | ||
unleashService, | ||
data: { | ||
redirectToLogout: "https://www.nav.no", | ||
context: "privatperson", | ||
simple: false, | ||
simpleHeader: false, | ||
simpleFooter: false, | ||
enforceLogin: false, | ||
redirectToApp: false, | ||
level: "Level3", | ||
language: "en", | ||
availableLanguages: [], | ||
breadcrumbs: [], | ||
utilsBackground: "transparent", | ||
feedback: false, | ||
chatbot: true, | ||
chatbotVisible: false, | ||
urlLookupTable: false, | ||
shareScreen: false, | ||
logoutUrl: "/logout", | ||
maskHotjar: true, | ||
logoutWarning: false, | ||
redirectToUrl: "https://www.nav.no", | ||
ssr: true, | ||
}, | ||
url: "localhost:8089/", | ||
}), | ||
).toContain("data-hj-supress"); | ||
test("It masks the document from hotjar", async () => { | ||
expect( | ||
await renderIndex({ | ||
data: { | ||
redirectToLogout: "https://www.nav.no", | ||
context: "privatperson", | ||
simple: false, | ||
simpleHeader: false, | ||
simpleFooter: false, | ||
enforceLogin: false, | ||
redirectToApp: false, | ||
level: "Level3", | ||
language: "en", | ||
availableLanguages: [], | ||
breadcrumbs: [], | ||
utilsBackground: "transparent", | ||
feedback: false, | ||
chatbot: true, | ||
chatbotVisible: false, | ||
urlLookupTable: false, | ||
shareScreen: false, | ||
logoutUrl: "/logout", | ||
maskHotjar: true, | ||
logoutWarning: false, | ||
redirectToUrl: "https://www.nav.no", | ||
ssr: true, | ||
}, | ||
url: "localhost:8089/", | ||
}), | ||
).toContain("data-hj-supress"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.