|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { resolveEffectiveDefaultWorkerGroupId } from "~/v3/regionAccess.server"; |
| 3 | + |
| 4 | +describe("resolveEffectiveDefaultWorkerGroupId", () => { |
| 5 | + it("prefers the environment default", () => { |
| 6 | + expect( |
| 7 | + resolveEffectiveDefaultWorkerGroupId({ |
| 8 | + environmentDefaultWorkerGroupId: "env", |
| 9 | + projectDefaultWorkerGroupId: "project", |
| 10 | + globalDefaultWorkerGroupId: "global", |
| 11 | + }) |
| 12 | + ).toBe("env"); |
| 13 | + }); |
| 14 | + |
| 15 | + it("falls back to the project default when the environment has none", () => { |
| 16 | + expect( |
| 17 | + resolveEffectiveDefaultWorkerGroupId({ |
| 18 | + environmentDefaultWorkerGroupId: null, |
| 19 | + projectDefaultWorkerGroupId: "project", |
| 20 | + globalDefaultWorkerGroupId: "global", |
| 21 | + }) |
| 22 | + ).toBe("project"); |
| 23 | + }); |
| 24 | + |
| 25 | + it("falls back to the global default when env and project have none", () => { |
| 26 | + expect( |
| 27 | + resolveEffectiveDefaultWorkerGroupId({ |
| 28 | + environmentDefaultWorkerGroupId: null, |
| 29 | + projectDefaultWorkerGroupId: null, |
| 30 | + globalDefaultWorkerGroupId: "global", |
| 31 | + }) |
| 32 | + ).toBe("global"); |
| 33 | + }); |
| 34 | + |
| 35 | + it("returns undefined when nothing is set", () => { |
| 36 | + expect( |
| 37 | + resolveEffectiveDefaultWorkerGroupId({ |
| 38 | + environmentDefaultWorkerGroupId: null, |
| 39 | + projectDefaultWorkerGroupId: null, |
| 40 | + globalDefaultWorkerGroupId: null, |
| 41 | + }) |
| 42 | + ).toBeUndefined(); |
| 43 | + }); |
| 44 | +}); |
0 commit comments