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
|
const { test } = require('tap')
const dedupe = require('../../lib/dedupe.js')
const requireInject = require('require-inject')
test('should remove dupes using Arborist', (t) => {
const dedupe = requireInject('../../lib/dedupe.js', {
'../../lib/npm.js': {
prefix: 'foo',
flatOptions: {
'dryRun': 'false'
}
},
'@npmcli/arborist': function (args) {
t.ok(args, 'gets options object')
t.ok(args.path, 'gets path option')
t.ok(args.dryRun, 'gets dryRun from user')
this.dedupe = () => {
t.ok(true, 'dedupe is called')
}
},
'../../lib/utils/reify-output.js': (arb) => {
t.ok(arb, 'gets arborist tree')
}
})
dedupe({ dryRun: true }, () => {
t.ok(true, 'callback is called')
t.end()
})
})
test('should remove dupes using Arborist - no arguments', (t) => {
const dedupe = requireInject('../../lib/dedupe.js', {
'../../lib/npm.js': {
prefix: 'foo',
flatOptions: {
'dryRun': 'true'
}
},
'@npmcli/arborist': function (args) {
t.ok(args.dryRun, 'gets dryRun from flatOptions')
this.dedupe = () => {}
},
'../../lib/utils/reify-output.js': () => {}
})
dedupe(null, () => {
t.end()
})
})
|