Skip to content
Merged
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
24 changes: 24 additions & 0 deletions test/get-client-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { getClientConfig } from "../app/config/client";

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

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

test("parses the config meta tag content on the client", () => {
const meta = document.createElement("meta");
meta.name = "config";
meta.content = JSON.stringify({ buildMode: "standalone", isApp: true });
document.head.appendChild(meta);
expect(getClientConfig()).toMatchObject({
buildMode: "standalone",
isApp: true,
});
});
});
Loading