Skip to content

Commit 484681e

Browse files
committed
add test for search invalid-module --json
1 parent 37bc790 commit 484681e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/lib/search.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,37 @@ t.test('search <name> --json', (t) => {
130130
src.end()
131131
})
132132

133+
t.test('search <invalid-module> --json', (t) => {
134+
const src = new Minipass()
135+
src.objectMode = true
136+
137+
npm.flatOptions.json = true
138+
config.json = true
139+
const libnpmsearch = {
140+
stream () {
141+
return src
142+
},
143+
}
144+
145+
const Search = t.mock('../../lib/search.js', {
146+
...mocks,
147+
libnpmsearch,
148+
})
149+
const search = new Search(npm)
150+
151+
search.exec(['foo'], (err) => {
152+
if (err)
153+
throw err
154+
155+
t.equal(result, '\n[]\n', 'should have expected empty square brackets')
156+
157+
config.json = false
158+
t.end()
159+
})
160+
161+
src.end()
162+
})
163+
133164
t.test('search <name> --searchexclude --searchopts', t => {
134165
npm.flatOptions.search = {
135166
...flatOptions.search,

0 commit comments

Comments
 (0)