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
|
'use strict'
var test = require('tap').test
var requireInject = require('require-inject')
var asap = require('asap')
// we're just mocking to avoid having to call `npm.load`
var deps = requireInject('../../lib/install/deps.js', {
'../../lib/npm.js': {
config: {
get: function () { return 'mock' }
},
limit: {
fetch: 10
}
}
})
var childDependencySpecifier = deps._childDependencySpecifier
test('childDependencySpecifier', function (t) {
var tree = {
resolved: {},
package: {
name: 'bar',
_requested: ''
}
}
childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
t.deepEqual(tree.resolved, {
foo: {
'^1.0.0': {
raw: 'foo@^1.0.0',
escapedName: 'foo',
scope: null,
name: 'foo',
rawSpec: '^1.0.0',
spec: '>=1.0.0 <2.0.0',
type: 'range'
}
}
}, 'should populate resolved')
var order = []
childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
order.push(1)
childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
order.push(3)
t.deepEqual(order, [1, 2, 3], 'should yield nested callbacks')
t.end()
})
})
asap(function () {
order.push(2)
})
})
})
|