mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
0c7b19b192
* chore: migrate core to vitest * chore: migrate url module * chore: migrate tarball package * chore: migrate loader package * chore: migrate hook package * chore: migrate signature package * chore: migrate utils package
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
|
|
import { getMatchedPackagesSpec } from '../src/matcher';
|
|
|
|
describe('getMatchedPackagesSpec', () => {
|
|
test('should test basic config', () => {
|
|
const packages = {
|
|
react: {
|
|
access: 'admin',
|
|
publish: 'admin',
|
|
proxy: 'facebook',
|
|
},
|
|
angular: {
|
|
access: 'admin',
|
|
publish: 'admin',
|
|
proxy: 'google',
|
|
},
|
|
'@*/*': {
|
|
access: '$all',
|
|
publish: '$authenticated',
|
|
proxy: 'npmjs',
|
|
},
|
|
'**': {
|
|
access: '$all',
|
|
publish: '$authenticated',
|
|
proxy: 'npmjs',
|
|
},
|
|
};
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('react', packages).proxy).toMatch('facebook');
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('angular', packages).proxy).toMatch('google');
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('vue', packages).proxy).toMatch('npmjs');
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('@scope/vue', packages).proxy).toMatch('npmjs');
|
|
});
|
|
|
|
test('should test no ** wildcard on config', () => {
|
|
const packages = {
|
|
react: {
|
|
access: 'admin',
|
|
publish: 'admin',
|
|
proxy: 'facebook',
|
|
},
|
|
angular: {
|
|
access: 'admin',
|
|
publish: 'admin',
|
|
proxy: 'google',
|
|
},
|
|
'@fake/*': {
|
|
access: '$all',
|
|
publish: '$authenticated',
|
|
proxy: 'npmjs',
|
|
},
|
|
};
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('react', packages).proxy).toMatch('facebook');
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('angular', packages).proxy).toMatch('google');
|
|
// @ts-expect-error
|
|
expect(getMatchedPackagesSpec('@fake/angular', packages).proxy).toMatch('npmjs');
|
|
expect(getMatchedPackagesSpec('vue', packages)).toBeUndefined();
|
|
expect(getMatchedPackagesSpec('@scope/vue', packages)).toBeUndefined();
|
|
});
|
|
});
|