0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/packages/core/tarball/tests/getLocalRegistryTarballUri.spec.ts

47 lines
1.2 KiB
TypeScript
Raw Normal View History

import { describe, expect, test } from 'vitest';
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',
},
},
'1.0.3': {
dist: {
tarball: 'http://registry.org/@org/npm_test/-/npm_test-1.0.3.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'
);
expect(extractTarballFromUrl(metadata.versions['1.0.3'].dist.tarball)).toEqual(
'npm_test-1.0.3.tgz'
);
});
});