-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
23 lines (18 loc) · 854 Bytes
/
test.js
File metadata and controls
23 lines (18 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const ctflags = require('./index.js');
console.log('Testing ctflags bindings...');
try {
const seed = ctflags.getSeedOrNull();
console.log('Seed:', seed);
const flag = ctflags.formatFlag('step1', 'somesalt');
console.log('Flag:', flag);
const flagContext = ctflags.formatFlagFromContext('ctx', 'step1', null);
console.log('Flag Context:', flagContext);
// Basic assertions
if (typeof seed !== 'string') throw new Error('getSeedOrNull failed');
if (typeof flag !== 'string' || !flag.startsWith('flag(step1).')) throw new Error('formatFlag failed: ' + flag);
if (typeof flagContext !== 'string' || !flagContext.startsWith('flag(step1).')) throw new Error('formatFlagFromContext failed: ' + flagContext);
console.log('SUCCESS');
} catch (error) {
console.error('FAILURE:', error);
process.exit(1);
}