-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.js
46 lines (36 loc) · 1.41 KB
/
root.js
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
import chai from 'chai';
import chaiHttp from 'chai-http';
chai.use(chaiHttp);
chai.should();
export const root = (api, route) => {
describe(`${route} route tests`, () => {
describe(`GET ${route}`, () => {
let response;
before(() => chai.request(api()).get(route).then(res => (response = res)));
it('should have 200 status', () => {
response.should.have.status(200);
});
it('should return an object', () => {
response.body.should.be.a('object');
});
it('should return hello world emojis', () => {
response.body.should.have.property('👋').eql('🌎');
});
it('should return project name', () => {
response.body.should.have.property('name');
response.body.name.should.be.a('String');
});
it('should return environment', () => {
response.body.should.have.property('environment').eql('test');
});
it('should return version', () => {
response.body.should.have.property('version');
response.body.version.should.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/);
});
it('should have a list of endpoints', () => {
response.body.should.have.property('endpoints');
response.body.endpoints.should.be.a('Array');
});
});
});
};