-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathxhrs_spec.js
More file actions
41 lines (32 loc) · 1.04 KB
/
xhrs_spec.js
File metadata and controls
41 lines (32 loc) · 1.04 KB
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('../spec_helper')
const xhrs = require(`../../lib/controllers/xhrs`)
describe('lib/controllers/xhr', () => {
describe('#parseHeaders', () => {
it('returns object literal on undefined', () => {
const obj = xhrs.parseHeaders(undefined)
expect(obj).to.deep.eq({
'content-type': 'text/plain',
})
})
it('uses passed in content-type', () => {
const obj = xhrs.parseHeaders({ 'content-type': 'application/json' }, 'foo')
expect(obj).to.deep.eq({
'content-type': 'application/json',
})
})
it('uses response if content-type is omitted', () => {
const obj = xhrs.parseHeaders({}, '<html>foo</html>')
expect(obj).to.deep.eq({
'content-type': 'text/html',
})
})
it('sets content-type to application/json', () => {
const str = JSON.stringify({ foo: 'bar' })
const obj = xhrs.parseHeaders({ 'x-token': '1234' }, str)
expect(obj).to.deep.eq({
'x-token': '1234',
'content-type': 'application/json',
})
})
})
})