From d8bd8b5bb33d87d9a2443d16b1dbbc310669bc90 Mon Sep 17 00:00:00 2001 From: Aaron Briggs <abriggs@contractor.usgs.gov> Date: Tue, 12 Jul 2022 11:28:17 -0500 Subject: [PATCH] domain tests --- .../components/hydrograph/selectors/domain.js | 1 - .../hydrograph/selectors/domain.test.js | 25 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.js index dab1eaf85..c2198c19f 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.js @@ -283,4 +283,3 @@ const getYTickDetails = memoize(tickKind => createSelector( export const getSecondaryYAxisTickDetails = getYTickDetails('secondary'); export const getPrimaryYAxisTickDetails = getYTickDetails('primary'); - diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.test.js index fbd2030b4..f48ce3575 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/domain.test.js @@ -6,7 +6,8 @@ import { } from '../mock-hydrograph-state'; import { extendDomain, - getYTickDetails, + getPrimaryYAxisTickDetails, + getSecondaryYAxisTickDetails, getFullArrayOfAdditionalTickMarks, getLowestAbsoluteValueOfTickValues, getRoundedTickValues, @@ -64,16 +65,32 @@ describe('monitoring-location/components/hydrograph/selectors/domain module', () }); }); - describe('getYTickDetails', () => { + describe('getPrimaryYAxisTickDetails', () => { it('Returns the default tick details if no parameter is defined', () => { - const tickDetails = getYTickDetails.resultFunc([0, 1], null); + const tickDetails = getPrimaryYAxisTickDetails.resultFunc([0, 1], null); expect(tickDetails.tickValues).toEqual(expect.any(Array)); expect(tickDetails.tickFormat).toEqual(expect.any(Function)); expect(tickDetails.tickFormat(1)).toEqual(expect.any(String)); }); it('returns ticks and a formatting function', () => { - const tickDetails = getYTickDetails.resultFunc([0, 1], {parameterCode: '00065'}); + const tickDetails = getPrimaryYAxisTickDetails.resultFunc([0, 1], {parameterCode: '00065'}); + expect(tickDetails.tickValues).toEqual(expect.any(Array)); + expect(tickDetails.tickFormat).toEqual(expect.any(Function)); + expect(tickDetails.tickFormat(1)).toEqual(expect.any(String)); + }); + }); + + describe('getSecondaryYAxisTickDetails', () => { + it('Returns the default tick details if no parameter is defined', () => { + const tickDetails = getSecondaryYAxisTickDetails.resultFunc([0, 1], null, [0, 1], null); + expect(tickDetails.tickValues).toEqual(expect.any(Array)); + expect(tickDetails.tickFormat).toEqual(expect.any(Function)); + expect(tickDetails.tickFormat(1)).toEqual(expect.any(String)); + }); + + it('returns ticks and a formatting function', () => { + const tickDetails = getSecondaryYAxisTickDetails.resultFunc([0, 1], null, [0, 1], {parameterCode: '00065'}); expect(tickDetails.tickValues).toEqual(expect.any(Array)); expect(tickDetails.tickFormat).toEqual(expect.any(Function)); expect(tickDetails.tickFormat(1)).toEqual(expect.any(String)); -- GitLab