-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathtest.js
49 lines (44 loc) · 1.12 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
const app = require('./app');
const server = app.listen();
const request = require('supertest').agent(server);
describe('Body Parsing', function() {
after(function() {
server.close();
});
describe('POST /uppercase', function() {
describe('with JSON', function() {
it('should work', function(done) {
request
.post('/uppercase')
.send({ name: 'tobi' })
.expect(200)
.expect({ name: 'TOBI' }, done);
});
});
describe('with urlencoded', function() {
it('should work', function(done) {
request
.post('/uppercase')
.send('name=tj')
.expect(200)
.expect({ name: 'TJ' }, done);
});
});
describe('when length > limit', function() {
it('should 413', function(done) {
request
.post('/json')
.send({ name: Array(5000).join('a') })
.expect(413, done);
});
});
describe('when no name is sent', function() {
it('should 400', function(done) {
request
.post('/uppsercase')
.send('age=10')
.expect(400, done);
});
});
});
});