Skip to content

Commit

Permalink
fix(plugins): support translations in local storage recent searches p…
Browse files Browse the repository at this point in the history
…lugins (#1286)

Closes #1285
  • Loading branch information
justinedelson authored Nov 15, 2024
1 parent 8467b7a commit 893ad5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,21 @@ describe('createLocalStorageRecentSearchesPlugin', () => {
const plugin = createLocalStorageRecentSearchesPlugin({
key: 'autocomplete',
limit: 3,
translations: {
fillQueryTitle: () => 'TEST',
},
});

expect(plugin.__autocomplete_pluginOptions).toEqual({
key: expect.any(String),
limit: expect.any(Number),
translations: {
fillQueryTitle: expect.any(Function),
},
});
expect(
plugin.__autocomplete_pluginOptions!.translations.fillQueryTitle()
).toBe('TEST');
});

test('exposes an API', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createLocalStorageRecentSearchesPlugin<
>(
options: LocalStorageRecentSearchesPluginOptions<TItem>
): AutocompletePlugin<TItem, RecentSearchesPluginData<TItem>> {
const { key, limit, transformSource, search, subscribe } =
const { key, limit, transformSource, search, subscribe, translations } =
getOptions(options);
const storage = createLocalStorage<TItem>({
key: [LOCAL_STORAGE_KEY, key].join(':'),
Expand All @@ -70,6 +70,7 @@ export function createLocalStorageRecentSearchesPlugin<
transformSource,
storage,
subscribe,
translations,
});

return {
Expand Down

0 comments on commit 893ad5f

Please sign in to comment.