|
1 | 1 | var fs = require('graceful-fs') |
2 | 2 | var path = require('path') |
3 | 3 |
|
4 | | -var mkdirp = require('mkdirp') |
5 | 4 | var mr = require('npm-registry-mock') |
6 | | -var osenv = require('osenv') |
7 | | -var rimraf = require('rimraf') |
8 | 5 | var test = require('tap').test |
9 | 6 |
|
10 | 7 | var common = require('../common-tap.js') |
@@ -42,8 +39,6 @@ var expected = { |
42 | 39 | } |
43 | 40 |
|
44 | 41 | test('setup', function (t) { |
45 | | - cleanup() |
46 | | - mkdirp.sync(pkg) |
47 | 42 | fs.writeFileSync( |
48 | 43 | path.join(pkg, 'package.json'), |
49 | 44 | JSON.stringify(json, null, 2) |
@@ -92,14 +87,37 @@ test('it should log json data', function (t) { |
92 | 87 | ) |
93 | 88 | }) |
94 | 89 |
|
| 90 | +test('it should log json data even when the list is empty', function (t) { |
| 91 | + common.npm( |
| 92 | + [ |
| 93 | + 'rm', |
| 94 | + 'request', |
| 95 | + 'underscore' |
| 96 | + ], |
| 97 | + EXEC_OPTS, |
| 98 | + function (er, code, stdout) { |
| 99 | + t.ifError(er, 'run without error') |
| 100 | + t.is(code, 0, 'successful exit status') |
| 101 | + common.npm( |
| 102 | + [ |
| 103 | + '--registry', common.registry, |
| 104 | + '--silent', |
| 105 | + '--json', |
| 106 | + 'outdated' |
| 107 | + ], |
| 108 | + EXEC_OPTS, |
| 109 | + function (er, code, stdout) { |
| 110 | + t.ifError(er, 'run without error') |
| 111 | + t.is(code, 0, 'successful exit status') |
| 112 | + t.same(JSON.parse(stdout), {}, 'got an empty object printed') |
| 113 | + t.end() |
| 114 | + } |
| 115 | + ) |
| 116 | + } |
| 117 | + ) |
| 118 | +}) |
| 119 | + |
95 | 120 | test('cleanup', function (t) { |
96 | 121 | server.close() |
97 | | - cleanup() |
98 | 122 | t.end() |
99 | 123 | }) |
100 | | - |
101 | | -function cleanup () { |
102 | | - // windows fix for locked files |
103 | | - process.chdir(osenv.tmpdir()) |
104 | | - rimraf.sync(pkg) |
105 | | -} |
|
0 commit comments