LGTM
This commit is contained in:
parent
9248e26af2
commit
f2a2651b8a
95 changed files with 3993 additions and 1471 deletions
|
|
@ -5,6 +5,7 @@ import { parseUrlState, stateToParams } from './url-state';
|
|||
import { INITIAL_VIEW_STATE } from './consts';
|
||||
import { createSchoolFilterKey } from './school-filter';
|
||||
import { createSpecificCrimeFilterKey } from './crime-filter';
|
||||
import { createElectionVoteShareFilterKey } from './election-filter';
|
||||
import { createEthnicityFilterKey } from './ethnicity-filter';
|
||||
import {
|
||||
POI_COUNT_2KM_FILTER_NAME,
|
||||
|
|
@ -168,6 +169,33 @@ describe('url-state', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('round-trips repeated election vote-share filters with dedicated URL params', () => {
|
||||
const labour = createElectionVoteShareFilterKey('% Labour', 1);
|
||||
const conservative = createElectionVoteShareFilterKey('% Conservative', 2);
|
||||
|
||||
const params = stateToParams(
|
||||
null,
|
||||
{
|
||||
[labour]: [30, 55],
|
||||
[conservative]: [10, 35],
|
||||
},
|
||||
[],
|
||||
new Set(),
|
||||
'area'
|
||||
);
|
||||
|
||||
expect(params.getAll('voteShare')).toEqual(['% Labour:30:55', '% Conservative:10:35']);
|
||||
expect(params.getAll('filter')).toEqual([]);
|
||||
|
||||
window.history.replaceState({}, '', `/?${params.toString()}`);
|
||||
const state = parseUrlState();
|
||||
|
||||
expect(state.filters).toEqual({
|
||||
[createElectionVoteShareFilterKey('% Labour', 0)]: [30, 55],
|
||||
[createElectionVoteShareFilterKey('% Conservative', 1)]: [10, 35],
|
||||
});
|
||||
});
|
||||
|
||||
it('round-trips repeated ethnicity filters with dedicated URL params', () => {
|
||||
const white = createEthnicityFilterKey('% White', 3);
|
||||
const southAsian = createEthnicityFilterKey('% South Asian', 4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue