-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI : Fix package existence check for scoped packages (#3044)
Fixes #2999
- Loading branch information
1 parent
16f163d
commit 6923e5b
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import test from 'ava'; | ||
const proxyquire = require('proxyquire').noCallThru(); | ||
|
||
test('existsOnNpm() builds the url for non-scoped packages', t => { | ||
let getUrl; | ||
const {existsOnNpm} = proxyquire('../../cli/api', { | ||
got: { | ||
get(url) { | ||
getUrl = url; | ||
return Promise.resolve({ | ||
body: { | ||
versions: [] | ||
} | ||
}); | ||
} | ||
}, | ||
'registry-url': () => 'https://registry.npmjs.org/' | ||
}); | ||
|
||
return existsOnNpm('pkg').then(() => { | ||
t.is(getUrl, 'https://registry.npmjs.org/pkg'); | ||
}); | ||
}); | ||
|
||
test('existsOnNpm() builds the url for scoped packages', t => { | ||
let getUrl; | ||
const {existsOnNpm} = proxyquire('../../cli/api', { | ||
got: { | ||
get(url) { | ||
getUrl = url; | ||
return Promise.resolve({ | ||
body: { | ||
versions: [] | ||
} | ||
}); | ||
} | ||
}, | ||
'registry-url': () => 'https://registry.npmjs.org/' | ||
}); | ||
|
||
return existsOnNpm('@scope/pkg').then(() => { | ||
t.is(getUrl, 'https://registry.npmjs.org/@scope%2fpkg'); | ||
}); | ||
}); |