mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
459b6fa72b
* Refactor local-storage async refactor local storage search stream Remove async from local-storage, refactor search with streams refactor search with undici fetch finish search refactor stream multiple request to single stream refactor storage types remove async dependency #1225 add score and refactor metadata remove old search async fix missing stream local data clean up clean up refactor folder search format fix some test fix issue on publish filter preview update ci delete package folder refactor refactor get packages methods fix tests fix lock file add changeset fix test windows disable some test update package json versions * fix merge * fix e2e cli * restore e2e * Update process.ts * Update process.ts * add improvement * format * Update utils.ts * test * test * Update search.spec.ts * Update search.spec.ts * Update search.spec.ts * test * Update ci.yml * clean up * fix tests * Update tags.ts * Update index.spec.ts * document changeset * format
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { join } from 'path';
|
|
import { getFolders, searchOnStorage } from '../src/dir-utils';
|
|
|
|
const mockFolder = join(__dirname, 'mockStorage');
|
|
|
|
const pathStorage1 = join(mockFolder, 'storage1');
|
|
const pathStorage2 = join(mockFolder, 'storage2');
|
|
const storages = new Map<string, string>();
|
|
storages.set('storage1', pathStorage1);
|
|
storages.set('storage2', pathStorage2);
|
|
|
|
test('getFolders storage 1', async () => {
|
|
const files = await getFolders(join(pathStorage1, '@bar'));
|
|
expect(files).toHaveLength(2);
|
|
expect(files).toEqual(['pkg1', 'pkg2']);
|
|
});
|
|
|
|
test('getFolders storage 2', async () => {
|
|
const files = await getFolders(pathStorage2);
|
|
expect(files).toHaveLength(1);
|
|
expect(files).toEqual(['pkg4']);
|
|
});
|
|
|
|
test('getFolders storage 2 with pattern', async () => {
|
|
const files = await getFolders(pathStorage1, '*bar*');
|
|
expect(files).toHaveLength(1);
|
|
expect(files).toEqual(['@bar']);
|
|
});
|
|
|
|
describe('searchOnFolders', () => {
|
|
test('should find results', async () => {
|
|
const packages = await searchOnStorage(mockFolder, storages);
|
|
expect(packages).toHaveLength(9);
|
|
expect(packages).toEqual([
|
|
{
|
|
name: '@foo/pkg1',
|
|
scoped: '@foo',
|
|
},
|
|
{
|
|
name: '@foo/pkg2',
|
|
scoped: '@foo',
|
|
},
|
|
{ name: 'dont-include' },
|
|
{
|
|
name: 'pkg1',
|
|
},
|
|
|
|
{
|
|
name: 'pkg2',
|
|
},
|
|
{
|
|
name: 'pkg3',
|
|
},
|
|
{
|
|
name: '@bar/pkg1',
|
|
scoped: '@bar',
|
|
},
|
|
{
|
|
name: '@bar/pkg2',
|
|
scoped: '@bar',
|
|
},
|
|
{
|
|
name: 'pkg4',
|
|
},
|
|
]);
|
|
});
|
|
});
|