Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/unit-deps-childDependencySpecifier.js')
-rw-r--r--deps/npm/test/tap/unit-deps-childDependencySpecifier.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/deps/npm/test/tap/unit-deps-childDependencySpecifier.js b/deps/npm/test/tap/unit-deps-childDependencySpecifier.js
new file mode 100644
index 00000000000..600b719fb2b
--- /dev/null
+++ b/deps/npm/test/tap/unit-deps-childDependencySpecifier.js
@@ -0,0 +1,56 @@
+'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' }
+ }
+ }
+})
+
+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)
+ })
+ })
+})