mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 12:38:39 -09:00
44 lines
1 KiB
TypeScript
44 lines
1 KiB
TypeScript
import test from 'ava';
|
|
const proxyquire = require('proxyquire').noCallThru();
|
|
|
|
test('existsOnNpm() builds the url for non-scoped packages', (t) => {
|
|
let getUrl: string;
|
|
const {existsOnNpm} = proxyquire('../../cli/api', {
|
|
got: {
|
|
get(url: string) {
|
|
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: string;
|
|
const {existsOnNpm} = proxyquire('../../cli/api', {
|
|
got: {
|
|
get(url: string) {
|
|
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');
|
|
});
|
|
});
|