|
| 1 | +import type { ExperimentalFeature } from './experimentalFeatures' |
1 | 2 | import { |
2 | 3 | updateExperimentalFeatures, |
3 | 4 | isExperimentalFeatureEnabled, |
4 | 5 | resetExperimentalFeatures, |
5 | 6 | } from './experimentalFeatures' |
6 | 7 |
|
| 8 | +const TEST_FEATURE_FLAG_ONE = 'foo' as ExperimentalFeature |
| 9 | +const TEST_FEATURE_FLAG_TWO = 'bar' as ExperimentalFeature |
| 10 | + |
7 | 11 | describe('experimentalFeatures', () => { |
8 | 12 | afterEach(() => { |
9 | 13 | resetExperimentalFeatures() |
10 | 14 | }) |
11 | 15 |
|
12 | 16 | it('initial state is empty', () => { |
13 | | - expect(isExperimentalFeatureEnabled('foo')).toBeFalse() |
14 | | - expect(isExperimentalFeatureEnabled('bar')).toBeFalse() |
| 17 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_ONE)).toBeFalse() |
| 18 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_TWO)).toBeFalse() |
15 | 19 | }) |
16 | 20 |
|
17 | 21 | it('should define enabled experimental features', () => { |
18 | | - updateExperimentalFeatures(['foo']) |
19 | | - expect(isExperimentalFeatureEnabled('foo')).toBeTrue() |
20 | | - expect(isExperimentalFeatureEnabled('bar')).toBeFalse() |
| 22 | + updateExperimentalFeatures([TEST_FEATURE_FLAG_ONE]) |
| 23 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_ONE)).toBeTrue() |
| 24 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_TWO)).toBeFalse() |
21 | 25 | }) |
22 | 26 |
|
23 | 27 | it('should allow to be shared between products', () => { |
24 | | - updateExperimentalFeatures(['foo']) |
25 | | - updateExperimentalFeatures(['bar']) |
| 28 | + updateExperimentalFeatures([TEST_FEATURE_FLAG_ONE]) |
| 29 | + updateExperimentalFeatures([TEST_FEATURE_FLAG_TWO]) |
26 | 30 |
|
27 | | - expect(isExperimentalFeatureEnabled('foo')).toBeTrue() |
28 | | - expect(isExperimentalFeatureEnabled('bar')).toBeTrue() |
| 31 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_ONE)).toBeTrue() |
| 32 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_TWO)).toBeTrue() |
29 | 33 | }) |
30 | 34 |
|
31 | 35 | it('should support some edge cases', () => { |
32 | | - updateExperimentalFeatures(['foo']) |
| 36 | + updateExperimentalFeatures([TEST_FEATURE_FLAG_ONE]) |
33 | 37 | updateExperimentalFeatures(undefined) |
34 | 38 | updateExperimentalFeatures([]) |
35 | 39 | updateExperimentalFeatures([11 as any]) |
36 | 40 |
|
37 | | - expect(isExperimentalFeatureEnabled('foo')).toBeTrue() |
| 41 | + expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG_ONE)).toBeTrue() |
38 | 42 | }) |
39 | 43 | }) |
0 commit comments