2024-08-03 12:39:22 -05:00
|
|
|
import { describe, expect, test } from 'vitest';
|
|
|
|
|
2024-01-06 07:25:07 -05:00
|
|
|
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',
|
|
|
|
},
|
|
|
|
},
|
2024-09-28 05:47:45 -05:00
|
|
|
'1.0.3': {
|
|
|
|
dist: {
|
|
|
|
tarball: 'http://registry.org/@org/npm_test/-/npm_test-1.0.3.tgz',
|
|
|
|
},
|
|
|
|
},
|
2024-01-06 07:25:07 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
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'
|
|
|
|
);
|
2024-09-28 05:47:45 -05:00
|
|
|
expect(extractTarballFromUrl(metadata.versions['1.0.3'].dist.tarball)).toEqual(
|
|
|
|
'npm_test-1.0.3.tgz'
|
|
|
|
);
|
2024-01-06 07:25:07 -05:00
|
|
|
});
|
|
|
|
});
|