Tonight
This commit is contained in:
parent
28323f145e
commit
94f9c0d594
76 changed files with 3238 additions and 1230 deletions
|
|
@ -3,6 +3,7 @@ import { beforeEach, describe, expect, it } from 'vitest';
|
|||
import type { FeatureMeta } from '../types';
|
||||
import { parseUrlState, stateToParams } from './url-state';
|
||||
import { createSchoolFilterKey } from './school-filter';
|
||||
import { createSpecificCrimeFilterKey } from './crime-filter';
|
||||
|
||||
describe('url-state', () => {
|
||||
beforeEach(() => {
|
||||
|
|
@ -110,6 +111,36 @@ describe('url-state', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('round-trips repeated specific crime filters with dedicated URL params', () => {
|
||||
const burglary = createSpecificCrimeFilterKey('Burglary (avg/yr)', 1);
|
||||
const vehicleCrime = createSpecificCrimeFilterKey('Vehicle crime (avg/yr)', 2);
|
||||
|
||||
const params = stateToParams(
|
||||
null,
|
||||
{
|
||||
[burglary]: [0, 5],
|
||||
[vehicleCrime]: [1, 10],
|
||||
},
|
||||
[],
|
||||
new Set(),
|
||||
'area'
|
||||
);
|
||||
|
||||
expect(params.getAll('crime')).toEqual([
|
||||
'Burglary (avg/yr):0:5',
|
||||
'Vehicle crime (avg/yr):1:10',
|
||||
]);
|
||||
expect(params.getAll('filter')).toEqual([]);
|
||||
|
||||
window.history.replaceState({}, '', `/?${params.toString()}`);
|
||||
const state = parseUrlState();
|
||||
|
||||
expect(state.filters).toEqual({
|
||||
[createSpecificCrimeFilterKey('Burglary (avg/yr)', 0)]: [0, 5],
|
||||
[createSpecificCrimeFilterKey('Vehicle crime (avg/yr)', 1)]: [1, 10],
|
||||
});
|
||||
});
|
||||
|
||||
it('omits the default area tab', () => {
|
||||
const params = stateToParams(null, {}, [], new Set(), 'area');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue