forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi3.delete.test.js
65 lines (43 loc) · 1.35 KB
/
api3.delete.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint require-atomic-updates: 0 */
'use strict';
require('should');
describe('API3 UPDATE', function() {
const self = this
, instance = require('./fixtures/api3/instance')
, authSubject = require('./fixtures/api3/authSubject')
;
self.timeout(15000);
before(async () => {
self.instance = await instance.create({});
self.app = self.instance.app;
self.env = self.instance.env;
self.url = '/api/v3/treatments';
let authResult = await authSubject(self.instance.ctx.authorization.storage, [
'delete'
], self.instance.app);
self.subject = authResult.subject;
self.jwt = authResult.jwt;
self.cache = self.instance.cacheMonitor;
});
after(() => {
self.instance.ctx.bus.teardown();
});
beforeEach(() => {
self.cache.clear();
});
afterEach(() => {
self.cache.shouldBeEmpty();
});
it('should require authentication', async () => {
let res = await self.instance.delete(`${self.url}/FAKE_IDENTIFIER`)
.expect(401);
res.body.status.should.equal(401);
res.body.message.should.equal('Missing or bad access token or JWT');
});
it('should not found not existing collection', async () => {
let res = await self.instance.delete(`/api/v3/NOT_EXIST`, self.jwt.delete)
.send(self.validDoc)
.expect(404);
res.body.status.should.equal(404);
});
});