-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: local search keyword undefined errors (#3992)
* fix: local search keyword undefined errors * Update indexer.ts
- Loading branch information
1 parent
e445db0
commit 35cc57b
Showing
6 changed files
with
696 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@verdaccio/search': patch | ||
--- | ||
|
||
fix: keyword undefined errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { expect, test } from 'vitest'; | ||
|
||
import { Logger } from '@verdaccio/types'; | ||
|
||
import { SearchMemoryIndexer } from '../src'; | ||
|
||
class MockStore { | ||
getLocalDatabase(cb) { | ||
return cb(null, [ | ||
{ | ||
name: 'verdaccio-search', | ||
version: '1.0.0', | ||
readme: 'foo', | ||
description: 'foo', | ||
keywords: ['foo', 'bar'], | ||
}, | ||
{ | ||
name: 'verdaccio-utils', | ||
version: '2.0.0', | ||
readme: 'foo', | ||
description: 'foo', | ||
keywords: 'some', | ||
}, | ||
]); | ||
} | ||
} | ||
|
||
const logger = { | ||
// eslint-disable-next-line no-console | ||
error: (...arg) => console.error(...arg), | ||
} as Logger; | ||
|
||
test('should search', async () => { | ||
const store = new MockStore(); | ||
|
||
SearchMemoryIndexer.configureStorage(store); | ||
await SearchMemoryIndexer.init(logger); | ||
// @ts-expect-error | ||
await SearchMemoryIndexer.add({ | ||
name: 'verdaccio', | ||
version: '2.0.0', | ||
readme: 'foo', | ||
description: '', | ||
}); | ||
const query = await SearchMemoryIndexer.query('verdaccio'); | ||
expect(query.hits.map((item) => item.id)).toEqual(['verdaccio', 'verdaccio-utils']); | ||
}); |
Oops, something went wrong.