Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2import * as Option from "effect/Option";
3
4import {
5 newEasDeviceHost,
6 parseEasDeviceHostDraft,
7 updateEasDeviceHosts,
8} from "./easDeviceHostsSettings.logic";
9
10describe("EAS device host settings", () => {
11 it("rejects limits EAS does not allow", () => {
12 expect(Option.isSome(parseEasDeviceHostDraft(newEasDeviceHost("eas")))).toBe(true);
13 expect(
14 Option.isNone(parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), maxSessionMinutes: 10 })),
15 ).toBe(true);
16 expect(
17 Option.isNone(
18 parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), maxSessionMinutes: 600 }),
19 ),
20 ).toBe(true);
21 expect(Option.isNone(parseEasDeviceHostDraft({ ...newEasDeviceHost("eas"), label: " " }))).toBe(
22 true,
23 );
24 });
25
26 it("keeps each environment's own token when a save leaves the token unchanged", () => {
27 const edited = { ...newEasDeviceHost("eas"), label: "Renamed", accessToken: "" };
28 const elsewhere = { ...newEasDeviceHost("eas"), accessToken: "••••••" };
29 expect(updateEasDeviceHosts([elsewhere], edited, false, true)).toEqual([
30 { ...edited, accessToken: "••••••" },
31 ]);
32 expect(updateEasDeviceHosts([], { ...edited, accessToken: "••••••" }, false, true)).toEqual([
33 { ...edited, accessToken: "" },
34 ]);
35 });
36});