reboot alterflixhub
This commit is contained in:
commit
1e84023a44
188 files changed
+31629
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolveInitialLocale } from "./index";
|
||||
|
||||
describe("resolveInitialLocale", () => {
|
||||
it("?lang= ชนะทุกแหล่ง", () => {
|
||||
expect(resolveInitialLocale({ urlLocale: "en", stored: "th", cookie: "th" })).toBe("en");
|
||||
expect(resolveInitialLocale({ urlLocale: "th", stored: "en", cookie: "en" })).toBe("th");
|
||||
});
|
||||
|
||||
it("ใช้ค่าที่เคยเลือก (localStorage) ก่อน cookie", () => {
|
||||
expect(resolveInitialLocale({ stored: "en", cookie: "th" })).toBe("en");
|
||||
});
|
||||
|
||||
it("ถ้าไม่มีใน localStorage ใช้ cookie", () => {
|
||||
expect(resolveInitialLocale({ cookie: "en" })).toBe("en");
|
||||
});
|
||||
|
||||
it("ไม่เคยเลือกเลย → ไทย (ไทย-first ไม่อิงภาษาของเบราว์เซอร์)", () => {
|
||||
expect(resolveInitialLocale({})).toBe("th");
|
||||
});
|
||||
|
||||
it("ค่าที่ไม่รู้จักถูกมองข้ามแล้วตกไปค่าเริ่มต้น", () => {
|
||||
expect(resolveInitialLocale({ urlLocale: "fr", stored: "xx", cookie: null })).toBe("th");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user