Simplify leaderboard rows and defer disruptive refreshes
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { expect, it, vi } from 'vitest';
|
||||
import { GET } from '../../src/routes/api/leaderboard/+server.js';
|
||||
import { load } from '../../src/routes/leaderboard/+page.server.js';
|
||||
vi.mock('../../src/routes/api/leaderboard/+server.js', () => ({ GET: vi.fn() }));
|
||||
it('requests the same 25-player page on initial load and preserves filters without mutating the page URL', async () => {
|
||||
vi.mocked(GET).mockResolvedValueOnce(new Response(JSON.stringify({ entries: [], limit: 25, offset: 25 })));
|
||||
const url = new URL('http://localhost/leaderboard?game=t5&map=theater&metric=kills&q=123&offset=25&limit=100');
|
||||
const original = url.href;
|
||||
const data = await load({ url });
|
||||
const requested = vi.mocked(GET).mock.calls[0][0].url;
|
||||
expect(requested.searchParams.get('limit')).toBe('25');
|
||||
for (const key of ['game', 'map', 'metric', 'q', 'offset']) expect(requested.searchParams.get(key)).toBe(url.searchParams.get(key));
|
||||
expect(url.href).toBe(original);
|
||||
expect(data.leaderboard.limit).toBe(25);
|
||||
});
|
||||
Reference in New Issue
Block a user