webRemoteControlThemeSeed.test.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { describe, expect, it } from "vitest";
  2. import { resolveWebRemoteControlInitialTheme } from "@web/webRemoteControlThemeSeed.js";
  3. describe("resolveWebRemoteControlInitialTheme", () => {
  4. it("uses the QR theme only when mobile localStorage has no theme", () => {
  5. expect(
  6. resolveWebRemoteControlInitialTheme({
  7. storedTheme: null,
  8. qrTheme: "zai-dark",
  9. }),
  10. ).toBe("zai-dark");
  11. });
  12. it("keeps the mobile local theme once the phone has chosen one", () => {
  13. expect(
  14. resolveWebRemoteControlInitialTheme({
  15. storedTheme: "light",
  16. qrTheme: "zai-dark",
  17. }),
  18. ).toBe("zai-light");
  19. });
  20. it("treats removed theme values as invalid", () => {
  21. expect(
  22. resolveWebRemoteControlInitialTheme({
  23. storedTheme: null,
  24. qrTheme: "legacy-dark",
  25. }),
  26. ).toBe("zai-dark");
  27. });
  28. it("falls back to the web default when neither side provides a valid theme", () => {
  29. expect(
  30. resolveWebRemoteControlInitialTheme({
  31. storedTheme: "midnight",
  32. qrTheme: undefined,
  33. }),
  34. ).toBe("zai-dark");
  35. });
  36. it("allows the share page to default to light without overriding an explicit theme", () => {
  37. expect(
  38. resolveWebRemoteControlInitialTheme({
  39. storedTheme: "midnight",
  40. qrTheme: undefined,
  41. defaultTheme: "zai-light",
  42. }),
  43. ).toBe("zai-light");
  44. expect(
  45. resolveWebRemoteControlInitialTheme({
  46. storedTheme: "zai-dark",
  47. qrTheme: undefined,
  48. defaultTheme: "zai-light",
  49. }),
  50. ).toBe("zai-dark");
  51. });
  52. });