Skip to content

Commit d09f7b1

Browse files
🧪 Add tests for promiseAny in utils.ts
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 3bdab5f commit d09f7b1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎src/__tests__/isInRollout.test.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
let importCount = 0;
21
import { describe, expect, it, mock } from 'bun:test';
32

43
// Use the preload setup file instead of inline mocks since bun resolves
@@ -48,39 +47,39 @@ describe('murmurhash3_32_gc', () => {
4847
describe('isInRollout', () => {
4948
it('should return true when the rollout is greater than the hash modulo', async () => {
5049
mockUuid = 'test1';
51-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
50+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
5251
expect(isInRollout(25)).toBe(true);
5352
});
5453

5554
it('should return false when the rollout is equal to the hash modulo', async () => {
5655
mockUuid = 'test1';
57-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
56+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
5857
expect(isInRollout(24)).toBe(false);
5958
});
6059

6160
it('should return false when the rollout is less than the hash modulo', async () => {
6261
mockUuid = 'test1';
63-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
62+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
6463
expect(isInRollout(23)).toBe(false);
6564
});
6665

6766
it('should evaluate correctly for a different uuid', async () => {
6867
mockUuid = 'test3';
69-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
68+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
7069
expect(isInRollout(1)).toBe(true);
7170
expect(isInRollout(0)).toBe(false);
7271
expect(isInRollout(-1)).toBe(false);
7372
});
7473

7574
it('should always return false for 0% rollout', async () => {
7675
mockUuid = 'test1';
77-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
76+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
7877
expect(isInRollout(0)).toBe(false);
7978
});
8079

8180
it('should always return true for 100% rollout', async () => {
8281
mockUuid = 'test1';
83-
const { isInRollout } = await import(`../isInRollout?id=${++importCount}`);
82+
const { isInRollout } = await import(`../isInRollout?id=${Date.now()}`);
8483
expect(isInRollout(100)).toBe(true);
8584
});
8685
});

0 commit comments

Comments
 (0)