/
snapshots-inline-js.test.js
69 lines (63 loc) · 1.61 KB
/
snapshots-inline-js.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { describe, expect, test } from 'vitest'
// when snapshots are generated Vitest reruns `toMatchInlineSnapshot` checks
// please, don't commit generated snapshots
describe('snapshots are generated in correct order', async () => {
test('first snapshot', () => {
expect({ foo: ['bar'] }).toMatchInlineSnapshot(`
Object {
"foo": Array [
"bar",
],
}
`)
})
test('second snapshot', () => {
expect({ foo: ['zed'] }).toMatchInlineSnapshot(`
Object {
"foo": Array [
"zed",
],
}
`)
})
})
describe('snapshots with properties', () => {
test('without snapshot', () => {
expect({ foo: 'bar' }).toMatchInlineSnapshot({ foo: expect.any(String) }, `
Object {
"foo": Any<String>,
}
`)
})
test('with snapshot', () => {
expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, `
Object {
"first": Object {
"second": Object {
"foo": Any<String>,
},
},
}
`)
})
test('mixed with and without snapshot', () => {
expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, `
Object {
"first": Object {
"second": Object {
"foo": Any<String>,
},
},
}
`)
expect({ first: { second: { foo: 'zed' } } }).toMatchInlineSnapshot(`
Object {
"first": Object {
"second": Object {
"foo": "zed",
},
},
}
`)
})
})