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
Marc Bernard 5cfbc1485d
fix(store): add logging when requesting tarball (#4847)
* fix(api): error handling when requesting tarball

* add tarball test for scoped packages

* update changeset

* add logging for tarball requests

* Revert

* Update violet-boxes-float.md
2024-09-28 12:47:45 +02:00

46 lines
1.2 KiB
TypeScript

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'
);
});
});