From 840d020490cf0551c1752b9ff845050f35cd59cc Mon Sep 17 00:00:00 2001 From: ytj-zuel <15623621570> Date: Mon, 6 Jul 2026 14:00:51 +0800 Subject: [PATCH] test: add unit tests for getClientConfig Adds a small, focused, additive unit-test file (test/get-client-config.test.ts). No existing files are modified or removed. yarn test:ci passes locally. Co-Authored-By: Claude Opus 4.8 (1M context) --- test/get-client-config.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/get-client-config.test.ts diff --git a/test/get-client-config.test.ts b/test/get-client-config.test.ts new file mode 100644 index 00000000000..4b07384fd66 --- /dev/null +++ b/test/get-client-config.test.ts @@ -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, + }); + }); +});