-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
103 lines (94 loc) · 1.83 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
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
const test = require('tape');
const clone = require('clone-deep');
const { set } = require('dot-prop');
const updateNestedDependencies = require('./');
const change = (pkg, key, value) => set(clone(pkg), key, value);
const packageOne = {
name: 'package-one',
version: '1.0.0',
dependencies: {
'package-two': '1.0.0',
}
};
const packageTwo = {
name: 'package-two',
version: '1.0.0',
peerDependencies: {
'package-three': '2.2.0',
}
};
const packageThree = {
name: 'package-three',
version: '2.2.0',
devDependencies: {
'package-one': '1.0.0'
}
};
test('Should return updated packages when all packages increase in version', (t) => {
const expected = [
{
name: 'package-one',
version: '1.0.1',
dependencies: {
'package-two': '2.0.0',
},
},
{
name: 'package-two',
version: '2.0.0',
peerDependencies: {
'package-three': '2.3.0',
}
},
{
name: 'package-three',
version: '2.3.0',
devDependencies: {
'package-one': '1.0.1'
}
}
];
t.deepEqual(
updateNestedDependencies([
change(packageOne, 'nextVersion', '1.0.1'),
change(packageTwo, 'nextVersion', '2.0.0'),
change(packageThree, 'nextVersion', '2.3.0'),
]),
expected,
);
t.end();
});
test('Should return updated packages when a package needs a patch as a result of updates', (t) => {
const expected = [
{
name: 'package-one',
version: '1.0.1',
dependencies: {
'package-two': '2.0.0',
},
},
{
name: 'package-two',
version: '2.0.0',
peerDependencies: {
'package-three': '2.3.0',
}
},
{
name: 'package-three',
version: '2.3.0',
devDependencies: {
'package-one': '1.0.1'
}
}
];
t.deepEqual(
updateNestedDependencies([
packageOne,
change(packageTwo, 'nextVersion', '2.0.0'),
change(packageThree, 'nextVersion', '2.3.0'),
]),
expected,
);
t.end();
});