-
Notifications
You must be signed in to change notification settings - Fork 9
/
prune-spec.js
106 lines (97 loc) · 2.15 KB
/
prune-spec.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'use strict'
const la = require('lazy-ass')
const is = require('check-more-types')
const debug = require('debug')('test')
const R = require('ramda')
/* eslint-env mocha */
describe('pruning snapshots', () => {
describe('pruning an object', () => {
const pruneSnapshotsInObject = require('./prune')().pruneSnapshotsInObject
it('prunes an object', () => {
const runtimeSnapshots = [
{
key: 'a',
specFile: 'foo.js'
}
]
const snapshots = {
a: 1,
b: 2,
c: 3
}
const pruned = pruneSnapshotsInObject(runtimeSnapshots, snapshots)
debug(pruned)
const expected = {
a: 1
}
la(
R.equals(pruned)(expected),
'invalid pruned',
pruned,
'should be',
expected
)
})
it('prunes an object 2', () => {
const runtimeSnapshots = [
{
key: 'a',
specFile: 'foo.js'
},
{
key: 'b',
specFile: 'foo.js'
}
]
const snapshots = {
a: 1,
b: 2,
c: 3
}
const pruned = pruneSnapshotsInObject(runtimeSnapshots, snapshots)
debug(pruned)
const expected = {
a: 1,
b: 2
}
la(
R.equals(pruned)(expected),
'invalid pruned',
pruned,
'should be',
expected
)
})
})
describe('end to end', () => {
const snapshot = require('.')
const prune = snapshot.prune
let dummyTestName
it('is a function', () => {
la(is.fn(prune))
})
it('is a dummy test', function () {
dummyTestName = this.test.fullTitle().trim()
debug('creating a snapshot for test "%s"', dummyTestName)
debug('from filename "%s"', __filename)
snapshot.core({
what: 42,
specName: dummyTestName,
__filename,
// avoid skipping pruning when running on CI server
opts: {
ci: false
}
})
})
it('prunes', () => {
const tests = [
{
file: __filename,
specName: dummyTestName
}
]
prune({ tests })
})
})
})