feat(config): add shared browser cookie policy
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from "bun:test";
|
||||
import { resolveI18n, makeT, resolveLang, translateHtml } from "../src/index.ts";
|
||||
import { I18N_RUNTIME, resolveI18n, makeT, resolveLang, translateHtml } from "../src/index.ts";
|
||||
|
||||
const i18n = resolveI18n(
|
||||
{
|
||||
@@ -27,6 +27,10 @@ test("resolveLang: cookie → Accept-Language → default", () => {
|
||||
expect(resolveLang(i18n, "xx", "de")).toBe("en"); // invalid cookie + unsupported header
|
||||
});
|
||||
|
||||
test("language changes use the shared browser cookie helper", () => {
|
||||
expect(I18N_RUNTIME).toContain('window.wrnCookies.set(cookieName, lang, "language", cookie)');
|
||||
});
|
||||
|
||||
test("translateHtml resolves data-t text and t:attr attributes", () => {
|
||||
const t = makeT(i18n, "en");
|
||||
const out = translateHtml('<input t:placeholder="ph"><span data-t="nav.home"></span>', t);
|
||||
|
||||
Reference in New Issue
Block a user