-
Notifications
You must be signed in to change notification settings - Fork 80
/
invalid_request.js
41 lines (35 loc) · 1.14 KB
/
invalid_request.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
'use strict';
// mocha defines to avoid JSHint breakage
/* global describe, it, before, beforeEach, after, afterEach */
var assert = require('../../utils/assert.js');
var preq = require('preq');
var server = require('../../utils/server.js');
describe('400 handling', function() {
this.timeout(20000);
before(function () { return server.start(); });
it('should return a proper 400 for an empty POST', function() {
return preq.post({
uri: server.config.hostPort,
headers: {
'content-type': 'foo/bar'
},
})
.catch(function(e) {
assert.deepEqual(e.status, 400);
assert.contentType(e, 'application/problem+json');
});
});
it('should return a proper 400 for an invalid POST', function() {
return preq.post({
uri: server.config.hostPort,
headers: {
'content-type': 'foo/bar'
},
body: 'baz'
})
.catch(function(e) {
assert.deepEqual(e.status, 400);
assert.contentType(e, 'application/problem+json');
});
});
});