mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
e61bd6c78f
* chore: update prettier@2.x * chore: prettier auto fix * chore: fake circleci we don't need it but I want make dissapear the error
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import { Config } from '@verdaccio/config';
|
|
import { configExample } from '@verdaccio/mock';
|
|
import { setup } from '@verdaccio/logger';
|
|
|
|
import { Storage } from '../src';
|
|
import { SearchInstance } from '../src/search';
|
|
|
|
setup([]);
|
|
|
|
const packages = [
|
|
{
|
|
name: 'test1',
|
|
description: 'description',
|
|
_npmUser: {
|
|
name: 'test_user',
|
|
},
|
|
},
|
|
{
|
|
name: 'test2',
|
|
description: 'description',
|
|
_npmUser: {
|
|
name: 'test_user',
|
|
},
|
|
},
|
|
{
|
|
name: 'test3',
|
|
description: 'description',
|
|
_npmUser: {
|
|
name: 'test_user',
|
|
},
|
|
},
|
|
];
|
|
|
|
describe('search', () => {
|
|
beforeAll(async function () {
|
|
const config = new Config(configExample());
|
|
const storage = new Storage(config);
|
|
await storage.init(config);
|
|
SearchInstance.configureStorage(storage);
|
|
packages.map(function (item) {
|
|
// @ts-ignore
|
|
SearchInstance.add(item);
|
|
});
|
|
});
|
|
|
|
test('search query item', () => {
|
|
const result = SearchInstance.query('t');
|
|
expect(result).toHaveLength(3);
|
|
});
|
|
|
|
test('search remove item', () => {
|
|
const item = {
|
|
name: 'test6',
|
|
description: 'description',
|
|
_npmUser: {
|
|
name: 'test_user',
|
|
},
|
|
};
|
|
// @ts-ignore
|
|
SearchInstance.add(item);
|
|
let result = SearchInstance.query('test6');
|
|
expect(result).toHaveLength(1);
|
|
SearchInstance.remove(item.name);
|
|
result = SearchInstance.query('test6');
|
|
expect(result).toHaveLength(0);
|
|
});
|
|
});
|