diff --git a/src/services/performanceDbApi.js b/src/services/performanceDbApi.js index c1967c1b..ca42240a 100644 --- a/src/services/performanceDbApi.js +++ b/src/services/performanceDbApi.js @@ -106,7 +106,7 @@ export function lpaOverviewQuery (lpa, params) { const entityCountsSelects = [] for (const { resource, dataset, entityCount } of params.entityCounts) { - if (entityCount && entityCount >= 0) { + if (Number.isInteger(entityCount) && entityCount >= 0) { entityCountsSelects.push(entityCountSelectFragment(dataset, resource, entityCount)) } } diff --git a/test/unit/performanceDbApi.test.js b/test/unit/performanceDbApi.test.js index 5d3f3047..c1fb07fe 100644 --- a/test/unit/performanceDbApi.test.js +++ b/test/unit/performanceDbApi.test.js @@ -48,11 +48,15 @@ describe('performanceDbApi', () => { it('uses params in the query', () => { const query = lpaOverviewQuery('local-authority:FOO', { datasetsFilter: ['dataset-one', 'dataset-two'], - entityCounts: [{ dataset: 'dataset-three', resource: 'r1', entityCount: 10 }] + entityCounts: [ + { dataset: 'dataset-three', resource: 'r1', entityCount: 10 }, + { dataset: 'dataset-four', resource: 'r2', entityCount: 0 }] }) expect(query).toContain('local-authority:FOO') expect(query).toContain('dataset-one') expect(query).toContain('dataset-two') + expect(query).toContain('dataset-three') + expect(query).toContain('dataset-four') }) })