-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathtest.js
41 lines (36 loc) · 973 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
37
38
39
40
41
require('should');
const app = require('./app');
const server = app.listen();
const request = require('supertest').agent(server);
describe('Flash Messages', function() {
after(function() {
server.close();
});
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);
});
});