Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { leaderboardReturnHref, playerContextHref, profileViewHref } from '../../src/lib/leaderboard-navigation.js';
|
||||
import {
|
||||
leaderboardReturnHref,
|
||||
playerContextHref,
|
||||
profileViewHref
|
||||
} from '../../src/lib/leaderboard-navigation.js';
|
||||
|
||||
describe('leaderboard profile navigation', () => {
|
||||
it('preserves leaderboard scope, search and page while starting profile history on its first page', () => {
|
||||
@@ -15,7 +19,9 @@ describe('leaderboard profile navigation', () => {
|
||||
});
|
||||
|
||||
it('keeps profile filters and return context through pagination and resets history pages on filter changes', () => {
|
||||
const current = new URL('http://localhost/leaderboard/players/101?returnTo=%2Fleaderboard%3Fq%3DAce&game=t5&map=t5%3Atheater&metric=highestRound&offset=25');
|
||||
const current = new URL(
|
||||
'http://localhost/leaderboard/players/101?returnTo=%2Fleaderboard%3Fq%3DAce&game=t5&map=t5%3Atheater&metric=highestRound&offset=25'
|
||||
);
|
||||
const next = new URL(profileViewHref(current, { offset: '50' }), current);
|
||||
expect(next.searchParams.get('offset')).toBe('50');
|
||||
expect(next.searchParams.get('returnTo')).toBe('/leaderboard?q=Ace');
|
||||
@@ -39,10 +45,20 @@ describe('leaderboard profile navigation', () => {
|
||||
});
|
||||
|
||||
it('restricts supplied return destinations to the local leaderboard', () => {
|
||||
for (const value of [null, '', 'https://example.com/leaderboard', '//example.com/leaderboard', '/leaderboard/players/101', '/leaderboard/../settings', '/leaderboard\\@example.com']) {
|
||||
for (const value of [
|
||||
null,
|
||||
'',
|
||||
'https://example.com/leaderboard',
|
||||
'//example.com/leaderboard',
|
||||
'/leaderboard/players/101',
|
||||
'/leaderboard/../settings',
|
||||
'/leaderboard\\@example.com'
|
||||
]) {
|
||||
expect(leaderboardReturnHref(value)).toBe('/leaderboard');
|
||||
}
|
||||
expect(leaderboardReturnHref('/leaderboard?q=A%26B&unrelated=drop#fragment')).toBe('/leaderboard?q=A%26B');
|
||||
expect(leaderboardReturnHref('/leaderboard?q=A%26B&unrelated=drop#fragment')).toBe(
|
||||
'/leaderboard?q=A%26B'
|
||||
);
|
||||
});
|
||||
|
||||
it('uses the displayed fallback scope when a shared leaderboard URL contains unknown filters', () => {
|
||||
|
||||
Reference in New Issue
Block a user