feat(ui): book browse field registry, facet and sort query helpers (#2571)
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import {
|
||||
bookFacetQueryParams,
|
||||
normalizeBookCollectionFilterParams,
|
||||
normalizeBookQueryParams,
|
||||
normalizeBookPageParams,
|
||||
parseFacetParams,
|
||||
toCollectionHttpParams,
|
||||
toIdsHttpParams,
|
||||
toPageHttpParams,
|
||||
@@ -39,6 +41,15 @@ describe('book query parameters', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('round-trips a selection through route params and drops unknown keys', () => {
|
||||
const selection = parseFacetParams([
|
||||
'genre:Comedy', 'genre:Drama', 'tag:Anthology', 'future_group:a:b', '__proto__:READ',
|
||||
]);
|
||||
expect(selection).toEqual({genre: ['Comedy', 'Drama'], tag: ['Anthology']});
|
||||
expect(bookFacetQueryParams(selection)).toEqual({facet: ['genre:Comedy', 'genre:Drama', 'tag:Anthology']});
|
||||
expect(bookFacetQueryParams({})).toEqual({facet: null});
|
||||
});
|
||||
|
||||
it('passes an empty sort through without imposing a default', () => {
|
||||
const normalized = normalizeBookQueryParams({
|
||||
facets: {},
|
||||
|
||||
Reference in New Issue
Block a user