-
Notifications
You must be signed in to change notification settings - Fork 532
/
prompt-next-step.test.js
80 lines (67 loc) · 1.68 KB
/
prompt-next-step.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
var test = require('tap').test;
var prompts = require('../src/cli/commands/protect/prompts').nextSteps;
test('wizard next steps include protect correctly', function(t) {
var res = prompts({}, false);
t.equal(res.length, 1, 'contains 1 entry');
t.equal(res[0].name, 'misc-add-test', 'only entry is test');
res = prompts(
{
scripts: {
test: 'snyk test',
},
},
false,
);
t.equal(res.length, 0, 'there are no next steps');
res = prompts(
{
scripts: {
test: 'snyk test',
postinstall: 'snyk protect',
},
},
{},
);
t.equal(
res.length,
0,
'there are no next steps when protect is already in place',
);
// now test if there's a patch it should apply the protect
res = prompts(
{
scripts: {
test: 'snyk test', // we're not interested in test atm
},
},
require('./fixtures/wizard-patch-answers.json'),
);
t.equal(res.length, 1, 'protect is included');
t.equal(res[0].name, 'misc-add-protect', 'only entry is protect');
// now test if there's a patch it should apply the protect
res = prompts(
{
scripts: {
test: 'snyk test', // we're not interested in test atm
},
},
require('./fixtures/wizard-patch-answers.json'),
);
t.equal(res.length, 1, 'protect is included');
t.equal(res[0].name, 'misc-add-protect', 'only entry is protect');
// these answers should not add any extra steps
res = prompts(
{
scripts: {
test: 'snyk test', // we're not interested in test atm
},
},
{
random: {
choice: 'update',
},
},
);
t.equal(res.length, 0, 'no next steps');
t.end();
});