0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/core/tarball/tests/getLocalRegistryTarballUri.spec.ts

37 lines
916 B
TypeScript
Raw Normal View History

import { extractTarballFromUrl } from '../src';
describe('extractTarballFromUrl', () => {
const metadata: any = {
name: 'npm_test',
versions: {
'1.0.0': {
dist: {
tarball: 'http://registry.org/npm_test/-/npm_test-1.0.0.tgz',
},
},
'1.0.1': {
dist: {
tarball: 'npm_test-1.0.1.tgz',
},
},
'1.0.2': {
dist: {
tarball: 'https://localhost/npm_test-1.0.2.tgz',
},
},
},
};
test('should return only name of tarball', () => {
expect(extractTarballFromUrl(metadata.versions['1.0.0'].dist.tarball)).toEqual(
'npm_test-1.0.0.tgz'
);
expect(extractTarballFromUrl(metadata.versions['1.0.1'].dist.tarball)).toEqual(
'npm_test-1.0.1.tgz'
);
expect(extractTarballFromUrl(metadata.versions['1.0.2'].dist.tarball)).toEqual(
'npm_test-1.0.2.tgz'
);
});
});