From 3262012c592d68a8c9fcf5b498f74f75b7a569cf Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Wed, 25 Mar 2020 15:51:03 -0400 Subject: [PATCH 01/11] save work --- src/PerCapita.jsx | 68 +++++++++++++++++++++++++++++++++++--------- src/PerCapita.less | 7 +++-- src/reducers/map.jsx | 15 ++++++++++ 3 files changed, 74 insertions(+), 16 deletions(-) diff --git a/src/PerCapita.jsx b/src/PerCapita.jsx index 149914ccf..4578fd9e8 100644 --- a/src/PerCapita.jsx +++ b/src/PerCapita.jsx @@ -1,36 +1,76 @@ import './PerCapita.less' -import { GEO_NORM_NONE, GEO_NORM_PER1000 } from './constants' +import { GEO_NORM_NONE, GEO_NORM_PER1000, knownFilters } from './constants' import { connect } from 'react-redux' import { dataNormalizationChanged } from './actions/map'; import React from 'react' export class PerCapita extends React.Component { + _setNormalization( val ) { + this.props.onDataNormalization( val ) + } + + _getRawButtonClass() { + return this.props.dataNormalization === GEO_NORM_NONE ? '' : 'deselected' + } + + _getPerCapButtonClass() { + if ( this.props.enablePer1000 ) { + return this.props.dataNormalization === GEO_NORM_NONE ? 'deselected' : '' + } + return 'a-btn__disabled' + } + render() { return (
-

Map Shading

- - +
+

Map Shading

+ + + +
) } } +/** + * helper function to determine if we have any filters selected so we can + * disable the Per 1000 Complaints button + * @param {object} query contains values for the filters, etc + * @returns {boolean} are we enabling the perCap + */ +export const validatePerCapFilters = query => { + const keys = [] + for ( let i = 0; i < knownFilters.length; i++ ) { + const filter = knownFilters[i] + if ( query[filter] && query[filter].length ) { + keys.push( filter ) + } + } + return keys.length === 0 +} + export const mapStateToProps = state => ( { - dataNormalization: state.map.dataNormalization + dataNormalization: state.map.dataNormalization, + enablePer1000: validatePerCapFilters( state.query ) } ); export const mapDispatchToProps = dispatch => ( { - onDataNormalization: ev => { - dispatch( dataNormalizationChanged( ev.target.value ) ) + onDataNormalization: value => { + dispatch( dataNormalizationChanged( value ) ) } } ); diff --git a/src/PerCapita.less b/src/PerCapita.less index 57a506410..f62f7bbec 100644 --- a/src/PerCapita.less +++ b/src/PerCapita.less @@ -1,7 +1,10 @@ @import (less) "base.less"; .per-capita { - select { - height: 34px; + button { + color: @black; + &.deselected { + background-color: @pacific-40; + } } } diff --git a/src/reducers/map.jsx b/src/reducers/map.jsx index 6569b4474..0b5190c92 100644 --- a/src/reducers/map.jsx +++ b/src/reducers/map.jsx @@ -120,6 +120,19 @@ export function processStatesError( state, action ) { } } +/** + * Handler for the update filter data normalization action + * + * @param {object} state the current state in the Redux store + * @returns {object} the new state for the Redux store + */ +export function updateFilterDataNormalization( state ) { + return { + ...state, + dataNormalization: GEO_NORM_NONE + }; +} + /** * Handler for the update data normalization action * @@ -166,6 +179,8 @@ export function _buildHandlerMap() { const handlers = {} handlers[actions.DATA_NORMALIZATION_SELECTED] = updateDataNormalization + handlers[actions.FILTER_CHANGED] = updateFilterDataNormalization + handlers[actions.FILTER_MULTIPLE_ADDED] = updateFilterDataNormalization handlers[actions.STATES_API_CALLED] = statesCallInProcess handlers[actions.STATES_RECEIVED] = processStatesResults handlers[actions.STATES_FAILED] = processStatesError From 6f6cd743b62521f52241badedc00ca5e7f548884 Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Wed, 25 Mar 2020 15:56:28 -0400 Subject: [PATCH 02/11] update snapshots --- src/__tests__/__snapshots__/App.spec.jsx.snap | 42 +++++----- .../__snapshots__/MapPanel.spec.jsx.snap | 82 ++++++++++--------- .../__snapshots__/PerCapita.spec.jsx.snap | 40 ++++----- .../__snapshots__/ResultsPanel.spec.jsx.snap | 82 ++++++++++--------- 4 files changed, 126 insertions(+), 120 deletions(-) diff --git a/src/__tests__/__snapshots__/App.spec.jsx.snap b/src/__tests__/__snapshots__/App.spec.jsx.snap index 0d57cf9fc..2a0b5a8e1 100644 --- a/src/__tests__/__snapshots__/App.spec.jsx.snap +++ b/src/__tests__/__snapshots__/App.spec.jsx.snap @@ -1227,31 +1227,31 @@ exports[`initial state renders without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
diff --git a/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap b/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap index de8487d45..69435fe23 100644 --- a/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap +++ b/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap @@ -80,30 +80,31 @@ exports[`component:MapPanel renders Print without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
@@ -234,30 +235,31 @@ exports[`component:MapPanel renders without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
diff --git a/src/__tests__/__snapshots__/PerCapita.spec.jsx.snap b/src/__tests__/__snapshots__/PerCapita.spec.jsx.snap index 7fb9ef7ab..d8f6ed5f8 100644 --- a/src/__tests__/__snapshots__/PerCapita.spec.jsx.snap +++ b/src/__tests__/__snapshots__/PerCapita.spec.jsx.snap @@ -4,28 +4,30 @@ exports[`component: PerCapita initial state renders without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
`; diff --git a/src/__tests__/__snapshots__/ResultsPanel.spec.jsx.snap b/src/__tests__/__snapshots__/ResultsPanel.spec.jsx.snap index e7a970467..b52ce3049 100644 --- a/src/__tests__/__snapshots__/ResultsPanel.spec.jsx.snap +++ b/src/__tests__/__snapshots__/ResultsPanel.spec.jsx.snap @@ -553,30 +553,31 @@ exports[`component:Results renders Map print mode without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
@@ -1129,30 +1130,31 @@ exports[`component:Results renders map panel without crashing 1`] = `
-

- Map Shading -

- - + Complaints per 1,000 population + +
From 92e70c86b09d01957d68619855ec7dbe144cef40 Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 10:13:15 -0400 Subject: [PATCH 03/11] update test coverage --- src/__tests__/PerCapita.spec.jsx | 8 ++++++-- src/__tests__/__snapshots__/PillPanel.spec.jsx.snap | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/__tests__/PerCapita.spec.jsx b/src/__tests__/PerCapita.spec.jsx index d967eab33..39fe02890 100644 --- a/src/__tests__/PerCapita.spec.jsx +++ b/src/__tests__/PerCapita.spec.jsx @@ -49,10 +49,14 @@ describe( 'component: PerCapita', () => { const state = { map: { dataNormalization: 'foo' - } + }, + query: {} } let actual = mapStateToProps( state ) - expect( actual ).toEqual( { dataNormalization: 'foo' } ) + expect( actual ).toEqual( { + dataNormalization: 'foo', + enablePer1000: true + } ) } ) } ) diff --git a/src/__tests__/__snapshots__/PillPanel.spec.jsx.snap b/src/__tests__/__snapshots__/PillPanel.spec.jsx.snap index e86723c0d..f6d3d5c9b 100644 --- a/src/__tests__/__snapshots__/PillPanel.spec.jsx.snap +++ b/src/__tests__/__snapshots__/PillPanel.spec.jsx.snap @@ -75,6 +75,15 @@ exports[`component:PillPanel renders without crashing 1`] = ` className="a-btn a-btn__link body-copy" onClick={[Function]} > + + + Clear all filters From 528b490e2db8ffdfe9161472e5bf237c22ab1d68 Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 10:40:36 -0400 Subject: [PATCH 04/11] save map coverage --- src/PerCapita.jsx | 1 - src/__tests__/PerCapita.spec.jsx | 32 +++++++++++++++++++++++++++++ src/reducers/__tests__/map.spec.jsx | 20 ++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/PerCapita.jsx b/src/PerCapita.jsx index 4578fd9e8..e1a7983ec 100644 --- a/src/PerCapita.jsx +++ b/src/PerCapita.jsx @@ -20,7 +20,6 @@ export class PerCapita extends React.Component { } return 'a-btn__disabled' } - render() { return (
diff --git a/src/__tests__/PerCapita.spec.jsx b/src/__tests__/PerCapita.spec.jsx index 39fe02890..6fc7fe4a0 100644 --- a/src/__tests__/PerCapita.spec.jsx +++ b/src/__tests__/PerCapita.spec.jsx @@ -8,6 +8,21 @@ import renderer from 'react-test-renderer' import { shallow } from 'enzyme' import thunk from 'redux-thunk' +function setupEnzyme() { + const props = { + dataNormalization: true, + enablePer1000: true, + onDataNormalization: jest.fn() + } + + const target = shallow(); + + return { + props, + target + } +} + function setupSnapshot() { const middlewares = [ thunk ] const mockStore = configureMockStore( middlewares ) @@ -29,6 +44,23 @@ describe( 'component: PerCapita', () => { let tree = target.toJSON() expect( tree ).toMatchSnapshot() } ) + + it('allows the user to trigger Complaints', () => { + const { target, props } = setupEnzyme() + const button = target.find('.raw'); + + button.simulate('click'); + expect(props.onDataNormalization).toHaveBeenCalled(); + }); + + it('allows the user to trigger Per 1000 Complaints', () => { + const { target, props } = setupEnzyme() + const button = target.find('.capita'); + + button.simulate('click'); + expect(props.onDataNormalization).toHaveBeenCalled(); + }); + } ) describe('mapDispatchToProps', () => { diff --git a/src/reducers/__tests__/map.spec.jsx b/src/reducers/__tests__/map.spec.jsx index a5355a442..4bf62f05f 100644 --- a/src/reducers/__tests__/map.spec.jsx +++ b/src/reducers/__tests__/map.spec.jsx @@ -32,6 +32,26 @@ describe( 'reducer:map', () => { } ) }) + describe('handles FILTER_CHANGED', ()=>{ + action = { + type: actions.FILTER_CHANGED, + value: 'FooBar' + } + expect( target( { dataNormalization: 'FooBar' }, action ) ).toEqual( { + dataNormalization: GEO_NORM_NONE + } ) + } ) + + describe( 'handles FILTER_MULTIPLE_ADDED', () => { + action = { + type: actions.FILTER_MULTIPLE_ADDED, + value: 'FooBar' + } + expect( target( { dataNormalization: 'FooBar' }, action ) ).toEqual( { + dataNormalization: GEO_NORM_NONE + } ) + }) + describe( 'handles STATES_API_CALLED actions', () => { action = { type: actions.STATES_API_CALLED, From 940f8944716794ccd327c601174b5466906c2aab Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 10:45:25 -0400 Subject: [PATCH 05/11] update test coverage --- src/__tests__/PerCapita.spec.jsx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/__tests__/PerCapita.spec.jsx b/src/__tests__/PerCapita.spec.jsx index 6fc7fe4a0..3b089af05 100644 --- a/src/__tests__/PerCapita.spec.jsx +++ b/src/__tests__/PerCapita.spec.jsx @@ -1,6 +1,6 @@ import configureMockStore from 'redux-mock-store' import { - mapDispatchToProps, mapStateToProps, PerCapita + mapDispatchToProps, mapStateToProps, PerCapita, validatePerCapFilters } from '../PerCapita' import { Provider } from 'react-redux' import React from 'react' @@ -92,5 +92,27 @@ describe( 'component: PerCapita', () => { } ) } ) + describe( 'validatePerCapFilters', () => { + it( 'handles no filters', () => { + const query = { + date: {}, + bogus: {}, + product: [] + } + + expect( validatePerCapFilters( query ) ).toBeTruthy() + } ) + + it( 'handles some filters', () => { + const query = { + date: {}, + bogus: {}, + product: [ { name: 'foo', value: 123 } ] + } + + expect( validatePerCapFilters( query ) ).toBeFalsy() + } ) + } ) + } ) From a34ed603f9e6ac89468cf3af77fe9afb0642813b Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 12:28:20 -0400 Subject: [PATCH 06/11] update test coverage, add warning message --- src/MapPanel.jsx | 9 ++++++++- src/PerCapita.jsx | 22 +++------------------- src/__tests__/PerCapita.spec.jsx | 26 +------------------------- src/__tests__/utils.spec.jsx | 25 ++++++++++++++++++++++++- src/utils.jsx | 19 ++++++++++++++++++- 5 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/MapPanel.jsx b/src/MapPanel.jsx index bbd6dca31..3747ebb99 100644 --- a/src/MapPanel.jsx +++ b/src/MapPanel.jsx @@ -3,12 +3,17 @@ import ActionBar from './ActionBar' import { connect } from 'react-redux' import DateIntervals from './DateIntervals' import ErrorBlock from './Error' +import { hasFiltersEnabled } from './utils' import Loading from './Dialogs/Loading' import MapToolbar from './MapToolbar' import PerCapita from './PerCapita' import React from 'react' import RowChart from './RowChart' import TileChartMap from './TileChartMap' +import Warning from './Warning' + +const WARNING_MESSAGE = 'Due to your filter selections, the "Complaints per ' + + '1,000" option has been disabled' export class MapPanel extends React.Component { render() { @@ -18,6 +23,7 @@ export class MapPanel extends React.Component { { this.props.error && } + { this.props.showWarning && }
@@ -34,7 +40,8 @@ export class MapPanel extends React.Component { const mapStateToProps = state => ( { error: state.map.error, - isLoading: state.map.isLoading + isLoading: state.map.isLoading, + showWarning: hasFiltersEnabled( state.query ) } ) export default connect( mapStateToProps )( MapPanel ) diff --git a/src/PerCapita.jsx b/src/PerCapita.jsx index e1a7983ec..ad7b3026b 100644 --- a/src/PerCapita.jsx +++ b/src/PerCapita.jsx @@ -1,7 +1,8 @@ import './PerCapita.less' -import { GEO_NORM_NONE, GEO_NORM_PER1000, knownFilters } from './constants' +import { GEO_NORM_NONE, GEO_NORM_PER1000 } from './constants' import { connect } from 'react-redux' import { dataNormalizationChanged } from './actions/map'; +import { hasFiltersEnabled } from './utils' import React from 'react' @@ -45,26 +46,9 @@ export class PerCapita extends React.Component { } } -/** - * helper function to determine if we have any filters selected so we can - * disable the Per 1000 Complaints button - * @param {object} query contains values for the filters, etc - * @returns {boolean} are we enabling the perCap - */ -export const validatePerCapFilters = query => { - const keys = [] - for ( let i = 0; i < knownFilters.length; i++ ) { - const filter = knownFilters[i] - if ( query[filter] && query[filter].length ) { - keys.push( filter ) - } - } - return keys.length === 0 -} - export const mapStateToProps = state => ( { dataNormalization: state.map.dataNormalization, - enablePer1000: validatePerCapFilters( state.query ) + enablePer1000: !hasFiltersEnabled( state.query ) } ); export const mapDispatchToProps = dispatch => ( { diff --git a/src/__tests__/PerCapita.spec.jsx b/src/__tests__/PerCapita.spec.jsx index 3b089af05..0f0fe0429 100644 --- a/src/__tests__/PerCapita.spec.jsx +++ b/src/__tests__/PerCapita.spec.jsx @@ -90,29 +90,5 @@ describe( 'component: PerCapita', () => { enablePer1000: true } ) } ) - } ) - - describe( 'validatePerCapFilters', () => { - it( 'handles no filters', () => { - const query = { - date: {}, - bogus: {}, - product: [] - } - - expect( validatePerCapFilters( query ) ).toBeTruthy() - } ) - - it( 'handles some filters', () => { - const query = { - date: {}, - bogus: {}, - product: [ { name: 'foo', value: 123 } ] - } - - expect( validatePerCapFilters( query ) ).toBeFalsy() - } ) - } ) - - + } } ) diff --git a/src/__tests__/utils.spec.jsx b/src/__tests__/utils.spec.jsx index 0a1fff05f..767fef73c 100644 --- a/src/__tests__/utils.spec.jsx +++ b/src/__tests__/utils.spec.jsx @@ -1,10 +1,11 @@ import { ariaReadoutNumbers, calculateDateInterval, clamp, coalesce, debounce, - getFullUrl, hashCode, shortIsoFormat + getFullUrl, hasFiltersEnabled, hashCode, shortIsoFormat } from '../utils' import { DATE_RANGE_MIN } from '../constants' import React from 'react' import moment from 'moment' +import { validatePerCapFilters } from '../PerCapita' describe('module::utils', () => { describe( 'ariaReadoutNumbers', () => { @@ -149,5 +150,27 @@ describe('module::utils', () => { expect( actual ).toEqual( uri ) } ); } ); + + describe( 'hasFiltersEnabled', () => { + it( 'handles no filters', () => { + const query = { + date: {}, + bogus: {}, + product: [] + } + + expect( hasFiltersEnabled( query ) ).toBeFalsy() + } ) + + it( 'handles some filters', () => { + const query = { + date: {}, + bogus: {}, + product: [ { name: 'foo', value: 123 } ] + } + + expect( hasFiltersEnabled( query ) ).toBeTruthy() + } ) + } ) }) diff --git a/src/utils.jsx b/src/utils.jsx index 679834175..f45b96e31 100644 --- a/src/utils.jsx +++ b/src/utils.jsx @@ -1,4 +1,4 @@ -import { DATE_RANGE_MIN, SLUG_SEPARATOR } from './constants' +import { DATE_RANGE_MIN, knownFilters, SLUG_SEPARATOR } from './constants' import moment from 'moment' /** @@ -107,6 +107,23 @@ export function hashCode( someString ) { return hash } +/** + * helper function to determine if we have any filters selected so we can + * disable the Per 1000 Complaints button + * @param {object} query contains values for the filters, etc + * @returns {boolean} are we enabling the perCap + */ +export function hasFiltersEnabled( query ) { + const keys = [] + for ( let i = 0; i < knownFilters.length; i++ ) { + const filter = knownFilters[i] + if ( query[filter] && query[filter].length ) { + keys.push( filter ) + } + } + return keys.length > 0 +} + /** * Creates a hash from an object * From aaa3a1960d9f205e9b6161212f767991a13f00ba Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 12:46:48 -0400 Subject: [PATCH 07/11] update test coverage --- src/__tests__/MapPanel.spec.jsx | 6 ++- src/__tests__/PerCapita.spec.jsx | 2 +- .../__snapshots__/MapPanel.spec.jsx.snap | 48 ++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/__tests__/MapPanel.spec.jsx b/src/__tests__/MapPanel.spec.jsx index 468fe2f93..939413386 100644 --- a/src/__tests__/MapPanel.spec.jsx +++ b/src/__tests__/MapPanel.spec.jsx @@ -21,12 +21,16 @@ function setupSnapshot( printMode ) { total: items.length }, map: { + product: [], state: [] }, query: { from: 0, size: 10, - tab: MODE_MAP + tab: MODE_MAP, + product: [ + { name: 'foo' } + ] }, results: { items diff --git a/src/__tests__/PerCapita.spec.jsx b/src/__tests__/PerCapita.spec.jsx index 0f0fe0429..2273893fa 100644 --- a/src/__tests__/PerCapita.spec.jsx +++ b/src/__tests__/PerCapita.spec.jsx @@ -90,5 +90,5 @@ describe( 'component: PerCapita', () => { enablePer1000: true } ) } ) - } + } ) } ) diff --git a/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap b/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap index 69435fe23..7402af954 100644 --- a/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap +++ b/src/__tests__/__snapshots__/MapPanel.spec.jsx.snap @@ -37,6 +37,28 @@ exports[`component:MapPanel renders Print without crashing 1`] = `
+
+ + + +
+
+ Due to your filter selections, the "Complaints per 1,000" option has been disabled +
+
+
@@ -99,7 +121,7 @@ exports[`component:MapPanel renders Print without crashing 1`] = ` Complaints
+
+ + + +
+
+ Due to your filter selections, the "Complaints per 1,000" option has been disabled +
+
+
@@ -254,7 +298,7 @@ exports[`component:MapPanel renders without crashing 1`] = ` Complaints
@@ -232,7 +232,7 @@ exports[`component:MapPanel renders without crashing 1`] = `
- Due to your filter selections, the "Complaints per 1,000" option has been disabled + Due to your filter selections, the “Complaints per 1,000” option has been disabled
From 06522e47957de81cd923ef435809b33aee57a32a Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 14:03:13 -0400 Subject: [PATCH 09/11] adding test coverage, allow for flag filters, update color styling --- src/PerCapita.less | 3 +++ src/__tests__/utils.spec.jsx | 10 ++++++++++ src/constants/index.jsx | 2 +- src/utils.jsx | 13 +++++++++---- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/PerCapita.less b/src/PerCapita.less index f62f7bbec..9806a743a 100644 --- a/src/PerCapita.less +++ b/src/PerCapita.less @@ -3,6 +3,9 @@ .per-capita { button { color: @black; + &:not(.a-btn__disabled) { + background-color: @pacific-80; + } &.deselected { background-color: @pacific-40; } diff --git a/src/__tests__/utils.spec.jsx b/src/__tests__/utils.spec.jsx index 767fef73c..bf392e1c7 100644 --- a/src/__tests__/utils.spec.jsx +++ b/src/__tests__/utils.spec.jsx @@ -171,6 +171,16 @@ describe('module::utils', () => { expect( hasFiltersEnabled( query ) ).toBeTruthy() } ) + + it( 'handles flag filters', () => { + const query = { + date: {}, + bogus: {}, + has_narrative: true + } + + expect( hasFiltersEnabled( query ) ).toBeTruthy() + } ) } ) }) diff --git a/src/constants/index.jsx b/src/constants/index.jsx index 6f66c11a1..c1ee7abce 100644 --- a/src/constants/index.jsx +++ b/src/constants/index.jsx @@ -38,7 +38,7 @@ export const knownFilters = [ 'product', 'state', 'submitted_via', - 'tag', + 'tags', 'timely', 'zip_code' ] diff --git a/src/utils.jsx b/src/utils.jsx index f45b96e31..f35623f5d 100644 --- a/src/utils.jsx +++ b/src/utils.jsx @@ -1,4 +1,6 @@ -import { DATE_RANGE_MIN, knownFilters, SLUG_SEPARATOR } from './constants' +import { + DATE_RANGE_MIN, flagFilters, knownFilters, SLUG_SEPARATOR +} from './constants' import moment from 'moment' /** @@ -115,9 +117,12 @@ export function hashCode( someString ) { */ export function hasFiltersEnabled( query ) { const keys = [] - for ( let i = 0; i < knownFilters.length; i++ ) { - const filter = knownFilters[i] - if ( query[filter] && query[filter].length ) { + const allFilters = knownFilters.concat( flagFilters ) + for ( let i = 0; i < allFilters.length; i++ ) { + const filter = allFilters[i] + // eslint-disable-next-line no-mixed-operators + if ( Array.isArray( query[filter] ) && query[filter].length || + query[filter] === true ) { keys.push( filter ) } } From 12dee9519319b72547cd73a8934c5d881b0e367e Mon Sep 17 00:00:00 2001 From: Richard Dinh Date: Thu, 26 Mar 2020 14:51:27 -0400 Subject: [PATCH 10/11] update tests, conditions --- src/PerCapita.jsx | 3 --- src/reducers/__tests__/map.spec.jsx | 37 +++++++++++++++++++++++++++++ src/reducers/map.jsx | 28 ++++++++++++++++++++-- src/utils.jsx | 12 +++++++++- 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/PerCapita.jsx b/src/PerCapita.jsx index ad7b3026b..228229e3c 100644 --- a/src/PerCapita.jsx +++ b/src/PerCapita.jsx @@ -26,9 +26,6 @@ export class PerCapita extends React.Component {

Map Shading

-