-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathresolveWindowOrg.test.ts
More file actions
63 lines (55 loc) · 1.74 KB
/
Copy pathresolveWindowOrg.test.ts
File metadata and controls
63 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { describe, expect, it } from "bun:test";
import { resolveWindowOrg } from "./resolveWindowOrg";
const base = {
windowOrgPending: false,
windowOrgId: "org-registry",
organizations: undefined,
organizationsErrored: false,
sessionOrgId: "org-session",
};
describe("resolveWindowOrg", () => {
it("waits while the registry read is pending", () => {
expect(
resolveWindowOrg({
...base,
windowOrgPending: true,
organizationsErrored: true,
}),
).toEqual({ kind: "wait" });
});
it("waits while the registry org exists and the list is loading", () => {
expect(resolveWindowOrg(base)).toEqual({ kind: "wait" });
});
it("is unresolvable when the registry org exists and the list failed", () => {
expect(resolveWindowOrg({ ...base, organizationsErrored: true })).toEqual({
kind: "unresolvable",
});
});
it("keeps the registry org when it is still a membership", () => {
expect(
resolveWindowOrg({
...base,
organizations: [{ id: "org-other" }, { id: "org-registry" }],
}),
).toEqual({ kind: "resolved", organizationId: "org-registry" });
});
it("falls back to the session org when the registry org is dead", () => {
expect(
resolveWindowOrg({ ...base, organizations: [{ id: "org-other" }] }),
).toEqual({ kind: "resolved", organizationId: "org-session" });
});
it("resolves to the session org with no registry org even if the list failed", () => {
expect(
resolveWindowOrg({
...base,
windowOrgId: null,
organizationsErrored: true,
}),
).toEqual({ kind: "resolved", organizationId: "org-session" });
});
it("waits when nothing can supply an org", () => {
expect(
resolveWindowOrg({ ...base, windowOrgId: null, sessionOrgId: undefined }),
).toEqual({ kind: "wait" });
});
});