Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/get-client-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getClientConfig } from "../app/config/client";

describe("getClientConfig (client side)", () => {
afterEach(() => {
document
.querySelectorAll("meta[name='config']")
.forEach((meta) => meta.remove());
});

test("returns an empty object when no config meta tag is present", () => {
expect(getClientConfig()).toEqual({});
});

test("parses the JSON payload from the config meta tag", () => {
const meta = document.createElement("meta");
meta.name = "config";
meta.content = JSON.stringify({ buildMode: "standalone", isApp: false });
document.head.appendChild(meta);

expect(getClientConfig()).toEqual({
buildMode: "standalone",
isApp: false,
});
});
});