|
1 | | -let importCount = 0; |
2 | 1 | import { describe, expect, it, mock } from 'bun:test'; |
3 | 2 |
|
4 | 3 | // Use the preload setup file instead of inline mocks since bun resolves |
@@ -48,39 +47,39 @@ describe('murmurhash3_32_gc', () => { |
48 | 47 | describe('isInRollout', () => { |
49 | 48 | it('should return true when the rollout is greater than the hash modulo', async () => { |
50 | 49 | mockUuid = 'test1'; |
51 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 50 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
52 | 51 | expect(isInRollout(25)).toBe(true); |
53 | 52 | }); |
54 | 53 |
|
55 | 54 | it('should return false when the rollout is equal to the hash modulo', async () => { |
56 | 55 | mockUuid = 'test1'; |
57 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 56 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
58 | 57 | expect(isInRollout(24)).toBe(false); |
59 | 58 | }); |
60 | 59 |
|
61 | 60 | it('should return false when the rollout is less than the hash modulo', async () => { |
62 | 61 | mockUuid = 'test1'; |
63 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 62 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
64 | 63 | expect(isInRollout(23)).toBe(false); |
65 | 64 | }); |
66 | 65 |
|
67 | 66 | it('should evaluate correctly for a different uuid', async () => { |
68 | 67 | mockUuid = 'test3'; |
69 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 68 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
70 | 69 | expect(isInRollout(1)).toBe(true); |
71 | 70 | expect(isInRollout(0)).toBe(false); |
72 | 71 | expect(isInRollout(-1)).toBe(false); |
73 | 72 | }); |
74 | 73 |
|
75 | 74 | it('should always return false for 0% rollout', async () => { |
76 | 75 | mockUuid = 'test1'; |
77 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 76 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
78 | 77 | expect(isInRollout(0)).toBe(false); |
79 | 78 | }); |
80 | 79 |
|
81 | 80 | it('should always return true for 100% rollout', async () => { |
82 | 81 | mockUuid = 'test1'; |
83 | | - const { isInRollout } = await import(`../isInRollout?id=${++importCount}`); |
| 82 | + const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`); |
84 | 83 | expect(isInRollout(100)).toBe(true); |
85 | 84 | }); |
86 | 85 | }); |
0 commit comments