]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ls-depth-unmet.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / ls-depth-unmet.js
1 var fs = require('graceful-fs')
2 var path = require('path')
3
4 var mkdirp = require('mkdirp')
5 var mr = require('npm-registry-mock')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var common = require('../common-tap')
11
12 var pkg = path.resolve(__dirname, 'ls-depth-unmet')
13
14 var EXEC_OPTS = { cwd: pkg }
15
16 var json = {
17   name: 'ls-depth-umnet',
18   author: 'Evan You',
19   version: '0.0.0',
20   dependencies: {
21     'test-package-with-one-dep': '0.0.0',
22     underscore: '1.5.1',
23     optimist: '0.6.0'
24   }
25 }
26
27 test('setup', function (t) {
28   cleanup()
29   mkdirp.sync(pkg)
30   fs.writeFileSync(
31     path.join(pkg, 'package.json'),
32     JSON.stringify(json, null, 2)
33   )
34   mr({ port: common.port }, function (er, s) {
35     common.npm(
36       [
37         '--registry', common.registry,
38         'install', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep'
39       ],
40       EXEC_OPTS,
41       function (er, c) {
42         t.ifError(er, 'setup installation ran without issue')
43         t.equal(c, 0)
44         s.close()
45         t.end()
46       }
47     )
48   })
49 })
50
51 test('npm ls --depth=0', function (t) {
52   common.npm(
53     ['ls', '--depth=0'],
54     EXEC_OPTS,
55     function (er, c, out) {
56       t.ifError(er, 'setup installation ran without issue')
57       t.equal(c, 1, 'ls barfed')
58       t.has(
59         out,
60         /UNMET DEPENDENCY optimist@0\.6\.0/,
61         'output contains optimist@0.6.0 and labeled as unmet dependency'
62       )
63       t.has(
64         out,
65         /mkdirp@0\.3\.5 extraneous/,
66         'output contains mkdirp@0.3.5 and labeled as extraneous'
67       )
68       t.has(
69         out,
70         /underscore@1\.3\.1 invalid/,
71         'output contains underscore@1.3.1 and labeled as invalid'
72       )
73       t.has(
74         out,
75         /test-package-with-one-dep@0\.0\.0\n/,
76         'output contains test-package-with-one-dep@0.0.0 and has no labels'
77       )
78       t.doesNotHave(
79         out,
80         /test-package@0\.0\.0/,
81         'output does not contain test-package@0.0.0 which is at depth=1'
82       )
83       t.end()
84     }
85   )
86 })
87
88 test('npm ls --depth=1', function (t) {
89   common.npm(
90     ['ls', '--depth=1'],
91     EXEC_OPTS,
92     function (er, c, out) {
93       t.ifError(er, 'setup installation ran without issue')
94       t.equal(c, 1, 'ls barfed')
95       t.has(
96         out,
97         /UNMET DEPENDENCY optimist@0\.6\.0/,
98         'output contains optimist@0.6.0 and labeled as unmet dependency'
99       )
100       t.has(
101         out,
102         /mkdirp@0\.3\.5 extraneous/,
103         'output contains mkdirp@0.3.5 and labeled as extraneous'
104       )
105       t.has(
106         out,
107         /underscore@1\.3\.1 invalid/,
108         'output contains underscore@1.3.1 and labeled as invalid'
109       )
110       t.has(
111         out,
112         /test-package-with-one-dep@0\.0\.0\n/,
113         'output contains test-package-with-one-dep@0.0.0 and has no labels'
114       )
115       t.has(
116         out,
117         /test-package@0\.0\.0/,
118         'output contains test-package@0.0.0 which is at depth=1'
119       )
120       t.end()
121     }
122   )
123 })
124
125 test('npm ls --depth=Infinity', function (t) {
126   // travis has a preconfigured depth=0, in general we can not depend
127   // on the default value in all environments, so explictly set it here
128   common.npm(
129     ['ls', '--depth=Infinity'],
130     EXEC_OPTS,
131     function (er, c, out) {
132       t.ifError(er, 'setup installation ran without issue')
133       t.equal(c, 1, 'ls barfed')
134       t.has(
135         out,
136         /UNMET DEPENDENCY optimist@0\.6\.0/,
137         'output contains optimist@0.6.0 and labeled as unmet dependency'
138       )
139       t.has(
140         out,
141         /mkdirp@0\.3\.5 extraneous/,
142         'output contains mkdirp@0.3.5 and labeled as extraneous'
143       )
144       t.has(
145         out,
146         /underscore@1\.3\.1 invalid/,
147         'output contains underscore@1.3.1 and labeled as invalid'
148       )
149       t.has(
150         out,
151         /test-package-with-one-dep@0\.0\.0\n/,
152         'output contains test-package-with-one-dep@0.0.0 and has no labels'
153       )
154       t.has(
155         out,
156         /test-package@0\.0\.0/,
157         'output contains test-package@0.0.0 which is at depth=1'
158       )
159       t.end()
160     }
161   )
162 })
163
164 test('cleanup', function (t) {
165   cleanup()
166   t.end()
167 })
168
169 function cleanup () {
170   process.chdir(osenv.tmpdir())
171   rimraf.sync(pkg)
172 }