forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.root.test.js
42 lines (30 loc) · 886 Bytes
/
api.root.test.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
'use strict';
const request = require('supertest');
require('should');
describe('Root REST API', function() {
const self = this
, instance = require('./fixtures/api/instance')
, semver = require('semver')
;
this.timeout(15000);
before(async () => {
self.instance = await instance.create({});
self.app = self.instance.app;
self.env = self.instance.env;
});
after(function after () {
self.instance.server.close();
});
it('GET /api/versions', async () => {
let res = await request(self.app)
.get('/api/versions')
.expect(200);
res.body.length.should.be.aboveOrEqual(3);
res.body.forEach(obj => {
const fields = Object.getOwnPropertyNames(obj);
fields.sort().should.be.eql(['url', 'version']);
semver.valid(obj.version).should.be.ok();
obj.url.should.startWith('/api');
});
});
});