-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.test.js
54 lines (38 loc) · 1.49 KB
/
app.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
50
51
52
53
54
const Doubler = require('@leading-agile/api-doubles')
const doublerConfig = require('./doubler.config')
const client = require("axios");
const expect = require('chai').expect
describe('application', () => {
let doubler
beforeEach(() => {
doubler = new Doubler
doubler.serve(doublerConfig)
})
afterEach(() => {
doubler.stop()
})
it('loads all doubles from config', () => {
expect(doubler.allDoubles).to.deep.equal(doublerConfig.doubles)
})
it('returns expected status when hitting registered endpoint', () => {
const getUrl = 'http://localhost:8001/clientlibs/utils.min.js'
return client.get(getUrl)
.then(response => expect(response).to.have.property('status',200))
}),
it('returns expected data from endpoint', () => {
const postUrl = 'http://localhost:8001/api/day'
return client.post(postUrl, {data: 'something'})
.then(response => {
expect(response).to.have.property('status',200)
expect(response.data).to.have.property('text', '{"success":true}')
})
}),
it('returns a file attachment', () => {
const url = 'http://localhost:8001/files/bundle.js'
return client.get(url)
.then(response => {
expect(response).to.have.property('status',200)
expect(response.data).to.equal("const foo = 'bar'")
})
})
})