forked from koajs/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
36 lines (32 loc) · 902 Bytes
/
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
require('should');
const app = require('./app');
const request = require('supertest').agent(app.listen());
describe('Flash Messages', function() {
it('GET should return an empty array', function(done) {
request
.get('/messages')
.expect(200)
.expect('content-type', 'application/json; charset=utf-8')
.expect('[]', done);
});
it('POST should return 204', function(done) {
request
.post('/messages')
.send('hello')
.expect(204, done);
});
it('GET should return the message', function(done) {
request
.get('/messages')
.expect(200)
.expect('content-type', 'application/json; charset=utf-8')
.expect('["hello"]', done);
});
it('GET should return no more messages', function(done) {
request
.get('/messages')
.expect(200)
.expect('content-type', 'application/json; charset=utf-8')
.expect('[]', done);
});
});