-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworking.test.js
More file actions
68 lines (56 loc) · 1.92 KB
/
working.test.js
File metadata and controls
68 lines (56 loc) · 1.92 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { OpenFeature } from '@openfeature/web-sdk';
import { SplitFactory } from '@splitsoftware/splitio-browserjs';
import { OpenFeatureSplitProvider } from '../../lib/js-split-provider';
describe('OpenFeature Split Provider - Working Integration Test', () => {
let client;
let provider;
let splitClient;
// Properly define the split treatments for localhost mode
const localFeatures = {
// Define features with proper structure
'my_feature': {
treatment: 'on',
config: '{"desc": "this is a test"}'
},
'some_other_feature': 'off',
'int_feature': '32',
'obj_feature': '{"key": "value"}'
};
beforeEach(async () => {
// Create client
const splitFactory = SplitFactory({
core: {
authorizationKey: 'localhost'
},
features: localFeatures
})
splitClient = splitFactory.client();
provider = new OpenFeatureSplitProvider(splitFactory);
OpenFeature.setProvider(provider);
OpenFeature.setContext({targetingKey: 'user1'})
client = OpenFeature.getClient('test');
});
afterEach(async () => {
await splitClient.destroy();
});
test('boolean treatment evaluations', async () => {
// Test the boolean value evaluation
const result = await client.getBooleanValue('my_feature', false);
expect(result).toBe(true);
});
// Add a test for string treatment
test('string treatment evaluations', async () => {
const result = await client.getStringValue('some_other_feature', 'default');
expect(result).toBe('off');
});
// Add a test for number treatment
test('number treatment evaluations', async () => {
const result = await client.getNumberValue('int_feature', 0);
expect(result).toBe(32);
});
// Add a test for object treatment
test('object treatment evaluations', async () => {
const result = await client.getObjectValue('obj_feature', {});
expect(result).toEqual({ key: 'value' });
});
});