forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi3.basic.test.js
42 lines (30 loc) · 994 Bytes
/
api3.basic.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('Basic REST API3', function() {
const self = this
, testConst = require('./fixtures/api3/const.json')
, instance = require('./fixtures/api3/instance')
;
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.ctx.bus.teardown();
});
it('GET /version', async () => {
let res = await request(self.app)
.get('/api/v3/version')
.expect(200);
const apiConst = require('../lib/api3/const.json')
, software = require('../package.json')
, result = res.body.result;
res.body.status.should.equal(200);
result.version.should.equal(software.version);
result.apiVersion.should.equal(apiConst.API3_VERSION);
result.srvDate.should.be.within(testConst.YEAR_2019, testConst.YEAR_2050);
});
});