-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathisInRollout.test.ts
More file actions
38 lines (31 loc) · 984 Bytes
/
isInRollout.test.ts
File metadata and controls
38 lines (31 loc) · 984 Bytes
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
import { describe, expect, test, mock, beforeAll } from 'bun:test';
mock.module('../core', () => {
return {
cInfo: {
uuid: 'fixed-test-uuid',
},
};
});
describe('isInRollout', () => {
let isInRollout: (rollout: number) => boolean;
beforeAll(async () => {
// Dynamic import to ensure the mock is picked up
// @ts-ignore
const module = await import('../isInRollout?deterministic');
isInRollout = module.isInRollout;
});
test('returns false when rollout is 0', () => {
expect(isInRollout(0)).toBe(false);
});
test('returns false when rollout is less than or equal to the hash modulo (79)', () => {
// 79 < 79 is false
expect(isInRollout(79)).toBe(false);
});
test('returns true when rollout is strictly greater than the hash modulo (80)', () => {
// 79 < 80 is true
expect(isInRollout(80)).toBe(true);
});
test('returns true when rollout is 100', () => {
expect(isInRollout(100)).toBe(true);
});
});