Skip to content

Commit

Permalink
add test for search invalid-module --json
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushRawal committed Sep 14, 2021
1 parent 37bc790 commit 484681e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/lib/search.js
Expand Up @@ -130,6 +130,37 @@ t.test('search <name> --json', (t) => {
src.end()
})

t.test('search <invalid-module> --json', (t) => {
const src = new Minipass()
src.objectMode = true

npm.flatOptions.json = true
config.json = true
const libnpmsearch = {
stream () {
return src
},
}

const Search = t.mock('../../lib/search.js', {
...mocks,
libnpmsearch,
})
const search = new Search(npm)

search.exec(['foo'], (err) => {
if (err)
throw err

t.equal(result, '\n[]\n', 'should have expected empty square brackets')

config.json = false
t.end()
})

src.end()
})

t.test('search <name> --searchexclude --searchopts', t => {
npm.flatOptions.search = {
...flatOptions.search,
Expand Down

0 comments on commit 484681e

Please sign in to comment.