-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelper.test.ts
More file actions
38 lines (30 loc) · 1.33 KB
/
helper.test.ts
File metadata and controls
38 lines (30 loc) · 1.33 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
import { describe, expect, test } from 'bun:test';
import { isExpVersion } from './helper';
describe('isExpVersion', () => {
test('should return false when config is null', () => {
expect(isExpVersion(null, '1.0.0')).toBe(false);
});
test('should return false when config is undefined', () => {
expect(isExpVersion(undefined, '1.0.0')).toBe(false);
});
test('should return false when config.rollout is missing', () => {
// @ts-expect-error
expect(isExpVersion({}, '1.0.0')).toBe(false);
});
test('should return false when rollout config for version is missing', () => {
expect(isExpVersion({ rollout: {} }, '1.0.0')).toBe(false);
});
test('should return false when rollout config for version is null', () => {
expect(isExpVersion({ rollout: { '1.0.0': null } }, '1.0.0')).toBe(false);
});
test('should return true when rollout is less than 100', () => {
expect(isExpVersion({ rollout: { '1.0.0': 50 } }, '1.0.0')).toBe(true);
expect(isExpVersion({ rollout: { '1.0.0': 0 } }, '1.0.0')).toBe(true);
});
test('should return false when rollout is 100', () => {
expect(isExpVersion({ rollout: { '1.0.0': 100 } }, '1.0.0')).toBe(false);
});
test('should return false when rollout is greater than 100', () => {
expect(isExpVersion({ rollout: { '1.0.0': 110 } }, '1.0.0')).toBe(false);
});
});