-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathpost.test.js
37 lines (34 loc) · 934 Bytes
/
post.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
describe('POST requests', function () {
var validPostBody = {
id: '241a4d44-5b90-41fa-9454-5aa6568087e4',
description: 'third foo',
orderNumber: 3
}
it('works when valid', function (done) {
hippie(app, swaggerSchema)
.post('/foos')
.send(validPostBody)
.end(function (err, res) {
expect(err).to.be.undefined()
done()
})
})
it('errors when the post body is invalid', function () {
expect(hippie(app, swaggerSchema)
.post('/foos')
.send({
bogus: 'post-body'
})
.end()
).to.be.rejectedWith(/Invalid format for parameter/)
})
it('errors when the post response is invalid', function (done) {
hippie(app, swaggerSchema)
.post('/invalid-foos')
.send(validPostBody)
.end(function (err) {
expect(err.message).to.match(/Response from \/invalid-foos failed validation/)
done()
})
})
})