From ec35be4ca77eb47e0ee66c34c09dcbd1a88a2fab Mon Sep 17 00:00:00 2001 From: Aaron Briggs <abriggs@contractor.usgs.gov> Date: Tue, 12 Jul 2022 15:17:12 -0500 Subject: [PATCH] tests for layout --- .../components/hydrograph/selectors/layout.js | 2 +- .../hydrograph/selectors/layout.test.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.js index cd58778a9..66bb1c850 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.js @@ -73,5 +73,5 @@ export const getLayout = memoize(kind => createSelector( } )); -export const getMainLayout = getLayout(); +export const getMainLayout = getLayout('MAIN'); export const getBrushLayout = getLayout('BRUSH'); \ No newline at end of file diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.test.js index 6e902fa2e..d969339ed 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/layout.test.js @@ -16,5 +16,24 @@ describe('monitoring-location/components/hydrograph/layout module', () => { expect(layout.width).toEqual(200); expect(layout.height).toEqual(200 * ASPECT_RATIO); expect(layout.windowWidth).toEqual(600); + expect(layout.margin.bottom).toEqual(5); + expect(layout.margin.top).toEqual(25); + expect(layout.margin.left).toEqual(45); + expect(layout.margin.right).toEqual(25); + }); + + it('expects that margins will adjust for secondary y-axis', () => { + const layout = getMainLayout.resultFunc(200, 600, { + tickValues: [5, 10, 15], + tickFormat: format('d') + }, '00065'); + + expect(layout.width).toEqual(200); + expect(layout.height).toEqual(200 * ASPECT_RATIO); + expect(layout.windowWidth).toEqual(600); + expect(layout.margin.bottom).toEqual(5); + expect(layout.margin.top).toEqual(25); + expect(layout.margin.left).toEqual(45); + expect(layout.margin.right).toEqual(45); }); }); -- GitLab