Public Access
feat(library): sort by rating and priority
This commit is contained in:
1 parent
bad11807e0
commit
03259d0515
4 files changed
+27
-12
No files matched your search
@@ -39,17 +39,17 @@ function renderLibrary(initialEntry = '/library') {
|
||||
|
||||
const typeInto = (value) => fireEvent.change(screen.getByRole('searchbox'), {target: {value}});
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.setItem('tbp_jwt', 'token');
|
||||
globalThis.fetch = vi.fn(async () => ({ok: true, status: 200, json: async () => page}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
describe('GameLibrary search', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.setItem('tbp_jwt', 'token');
|
||||
globalThis.fetch = vi.fn(async () => ({ok: true, status: 200, json: async () => page}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
it('writes the trimmed search to the URL after the delay and resets the page', async () => {
|
||||
const lib = renderLibrary('/library?page=3');
|
||||
|
||||
@@ -93,3 +93,12 @@ describe('GameLibrary search', () => {
|
||||
await waitFor(() => expect(screen.getByRole('searchbox').value).toBe(''));
|
||||
});
|
||||
});
|
||||
|
||||
describe('GameLibrary sort', () => {
|
||||
it.each(['rating,desc', 'priority,desc'])('sends the sort %s from the URL', async (sort) => {
|
||||
renderLibrary(`/library?sort=${encodeURIComponent(sort)}`);
|
||||
|
||||
await waitFor(() => expect(fetch).toHaveBeenCalled());
|
||||
expect(new URL(fetch.mock.calls[0][0], 'http://x').searchParams.get('sort')).toBe(sort);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user