hyper/test/unit/cli-api.test.ts

46 lines
1.1 KiB
TypeScript
Raw Normal View History

import test from 'ava';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const proxyquire = require('proxyquire').noCallThru();
2020-03-25 02:15:08 -08:00
test('existsOnNpm() builds the url for non-scoped packages', (t) => {
2019-12-13 21:31:15 -09:00
let getUrl: string;
const {existsOnNpm} = proxyquire('../../cli/api', {
got: {
2019-12-13 21:31:15 -09:00
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');
});
});
2020-03-25 02:15:08 -08:00
test('existsOnNpm() builds the url for scoped packages', (t) => {
2019-12-13 21:31:15 -09:00
let getUrl: string;
const {existsOnNpm} = proxyquire('../../cli/api', {
got: {
2019-12-13 21:31:15 -09:00
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');
});
});