Skip to content
Source
Sign inSign up

browserProfile.test.ts

37 lines1.1 KB

1import { describe, expect, it } from "@effect/vitest";
2​
3import {
4 BUILT_IN_BROWSER_PROFILES,
5 DEFAULT_BROWSER_PROFILE_ID,
6 INCOGNITO_BROWSER_PROFILE_ID,
7 resolveBrowserProfiles,
8 type BrowserProfile,
9} from "./browserProfile.ts";
10​
11const work: BrowserProfile = { id: "profile-work", name: "Work", kind: "persistent" };
12​
13describe("resolveBrowserProfiles", () => {
14 it("drops stored entries that collide with a built-in id", () => {
15 const resolved = resolveBrowserProfiles([
16 { id: DEFAULT_BROWSER_PROFILE_ID, name: "Hijacked", kind: "persistent" },
17 { id: INCOGNITO_BROWSER_PROFILE_ID, name: "Not incognito", kind: "persistent" },
18 work,
19 ]);
20​
21 expect(resolved).toEqual([...BUILT_IN_BROWSER_PROFILES, work]);
22 });
23});
24​
25describe("resolveBrowserProfiles normalization", () => {
26 it("reports a custom incognito profile as persistent", () => {
27 const resolved = resolveBrowserProfiles([
28 { id: "throwaway", name: "Throwaway", kind: "incognito" },
29 ]);
30​
31 expect(resolved.find((profile) => profile.id === "throwaway")).toEqual({
32 id: "throwaway",
33 name: "Throwaway",
34 kind: "persistent",
35 });
36 });
37});