]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/outdated.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / outdated.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 rimraf = require('rimraf')
7 var test = require('tap').test
8
9 var npm = require('../../')
10 var common = require('../common-tap.js')
11
12 // config
13 var pkg = path.resolve(__dirname, 'outdated')
14 var cache = path.resolve(pkg, 'cache')
15 var originalLog
16
17 var json = {
18   name: 'outdated',
19   description: 'fixture',
20   version: '0.0.1',
21   dependencies: {
22     underscore: '1.3.1',
23     async: '0.2.9',
24     checker: '0.5.1'
25   }
26 }
27
28 test('setup', function (t) {
29   cleanup()
30   originalLog = console.log
31   mkdirp.sync(cache)
32   fs.writeFileSync(
33     path.join(pkg, 'package.json'),
34     JSON.stringify(json, null, 2)
35   )
36
37   process.chdir(pkg)
38   t.end()
39 })
40
41 test('it should not throw', function (t) {
42   var output = []
43   var expOut = [
44     path.resolve(pkg, 'node_modules', 'async') +
45       ':async@0.2.9' +
46       ':async@0.2.9' +
47       ':async@0.2.10' +
48       '\n' +
49     path.resolve(pkg, 'node_modules', 'checker') +
50       ':checker@0.5.1' +
51       ':checker@0.5.1' +
52       ':checker@0.5.2' +
53       '\n' +
54     path.resolve(pkg, 'node_modules', 'underscore') +
55       ':underscore@1.3.1' +
56       ':underscore@1.3.1' +
57       ':underscore@1.5.1'
58   ]
59
60   var expData = [
61     [
62       pkg,
63       'async',
64       '0.2.9',
65       '0.2.9',
66       '0.2.10',
67       '0.2.9'
68     ],
69     [
70       pkg,
71       'checker',
72       '0.5.1',
73       '0.5.1',
74       '0.5.2',
75       '0.5.1'
76     ],
77     [
78       pkg,
79       'underscore',
80       '1.3.1',
81       '1.3.1',
82       '1.5.1',
83       '1.3.1'
84     ]
85   ]
86
87   console.log = function () {}
88   mr({ port: common.port }, function (er, s) {
89     npm.load(
90       {
91         cache: 'cache',
92         loglevel: 'silent',
93         parseable: true,
94         registry: common.registry
95       },
96       function () {
97         npm.install('.', function (err) {
98           t.ifError(err, 'install success')
99           console.log = function () {
100             output.push.apply(output, arguments)
101           }
102           npm.outdated(function (er, d) {
103             t.ifError(er, 'outdated success')
104
105             console.log = originalLog
106
107             t.same(output, expOut)
108             t.same(d, expData)
109
110             s.close()
111             t.end()
112           })
113         })
114       }
115     )
116   })
117 })
118
119 test('cleanup', function (t) {
120   cleanup()
121   console.log = originalLog
122   t.end()
123 })
124
125 function cleanup () {
126   rimraf.sync(pkg)
127 }