-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsplitNames.test.js
More file actions
30 lines (27 loc) · 1.07 KB
/
splitNames.test.js
File metadata and controls
30 lines (27 loc) · 1.07 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
const request = require('supertest');
const app = require('../../app');
const { expectError } = require('../../utils/testWrapper');
describe('names', () => {
// Testing authorization
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/manager/names');
expectError(response, 401, 'Unauthorized');
});
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/manager/names')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
});
test('should be 200 and retuns the feature flags defined in YAML', async () => {
const response = await request(app)
.get('/manager/names')
.set('Authorization', 'test');
expect(response.statusCode).toBe(200);
expect(response.body).toHaveProperty('splits');
expect(response.body.splits.length).toEqual(4);
expect(response.body.splits)
.toEqual(expect.arrayContaining(['my-experiment', 'other-experiment-3', 'other-experiment', 'other-experiment-2']));
});
});