-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsplits.test.js
More file actions
29 lines (26 loc) · 981 Bytes
/
splits.test.js
File metadata and controls
29 lines (26 loc) · 981 Bytes
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
const request = require('supertest');
const app = require('../../app');
const { expectError } = require('../../utils/testWrapper');
describe('splits', () => {
// Testing authorization
test('should be 401 if auth is not passed', async () => {
const response = await request(app)
.get('/manager/splits');
expectError(response, 401, 'Unauthorized');
});
test('should be 401 if auth does not match', async () => {
const response = await request(app)
.get('/manager/splits')
.set('Authorization', 'invalid');
expectError(response, 401, 'Unauthorized');
});
test('should be 200 and returns the feature flags added in YAML', async () => {
const response = await request(app)
.get('/manager/splits')
.set('Authorization', 'test');
expect(response.statusCode).toBe(200);
expect(response.body).toHaveProperty('splits');
const keys = Object.keys(response.body.splits);
expect(keys.length).toEqual(4);
});
});