-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
48 lines (38 loc) · 1.24 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
/* eslint-env jest */
const serializer = require('./')
expect.addSnapshotSerializer(serializer)
test('should not serialize non-HTTP response', () => {
const object = { foo: 'bar', null: null, undefined: undefined }
expect(object).toMatchSnapshot()
})
test('should serialize HTTP response', () => {
const object = { status: 200, body: { hello: 'world' } }
expect(object).toMatchSnapshot()
})
test('should serialize HTTP Buffer response', () => {
const object = { statusCode: 200, body: Buffer.from('{ "Hello": "World" }') }
expect(object).toMatchSnapshot()
})
test('should serialize LightMyRequest HTTP response', () => {
const object = { statusCode: 200, body: '{ "Hello": "World" }' }
expect(object).toMatchSnapshot()
})
test('should not serialize null', () => {
expect(null).toMatchSnapshot()
})
test('should not serialize undefined', () => {
expect(undefined).toMatchSnapshot()
})
test('should not serialize array', () => {
expect([true, 'a', 1, { foo: 'bar' }, null, undefined]).toMatchSnapshot()
})
test('should sort required properties in arrays', () => {
const object = {
status: 200,
body: [
{ hello: 'world', foo: 'bar' },
{ hello: 'gilles', foo: 'baz' }
]
}
expect(object).toMatchSnapshot()
})