/
test.js
54 lines (46 loc) · 1.37 KB
/
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
import chronicle, { supertest } from '../../src';
import app from './app';
const request = supertest(app);
function contextBuilder({ test }) {
return {
title : test.title,
group : test.parent.title
};
}
before(async () => {
chronicle.setContextBuilder(contextBuilder);
});
suite('Users');
test('Positive: show user profile', async function () {
await request
.with(this)
.get('/users/:id')
.params({ id: 1 })
.expect('Content-Type', /json/)
.expect(200);
});
test('Positive: change user name', async function () {
await request
.with(this)
.patch('/users/:id')
.params({ id: 2 })
.set({ 'AUTH': '5NM2p40Z8' })
.send({ name: 'McCoy' })
.expect('Content-Type', /json/)
.expect(200);
});
suite('Messages');
test('Positive: get list of messages', async function () {
await request
.with(this)
.get('/messages?sender=2&limit=5')
.set({ 'AUTH': '5NM2p40Z8' })
.send({ name: 'McCoy' })
.expect('Content-Type', /json/)
.expect(200);
});
after(async () => {
await chronicle.save('./documentation/swagger.json', { reporter: 'swagger' });
await chronicle.save('./documentation/api-blueprint.md', { reporter: 'api-blueprint' });
chronicle.clear();
});