From b6bef7a9b96289874a596e1328722adab887f5a4 Mon Sep 17 00:00:00 2001
From: Mary Bucknell <mbucknell@usgs.gov>
Date: Tue, 13 Feb 2018 13:51:54 -0600
Subject: [PATCH] Added test for toggling the time series label. Also
 backfilled tests for resize timeseries plot.

---
 .../components/hydrograph/index.spec.js       | 15 ++++++--
 .../components/hydrograph/store.spec.js       | 34 ++++++++++++++++++-
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/assets/src/scripts/components/hydrograph/index.spec.js b/assets/src/scripts/components/hydrograph/index.spec.js
index 25276dbd2..f3ff11db5 100644
--- a/assets/src/scripts/components/hydrograph/index.spec.js
+++ b/assets/src/scripts/components/hydrograph/index.spec.js
@@ -100,10 +100,11 @@ describe('Hydrograph charting module', () => {
         });
     });
 
-    describe('with real data from site #05370000', () => {
+    describe('SVG contains the expected elements', () => {
         /* eslint no-use-before-define: "ignore" */
+        let store;
         beforeEach(() => {
-            const store = configureStore({
+            store = configureStore({
                 tsData: {
                     current: [{
                         time: new Date(),
@@ -123,6 +124,7 @@ describe('Hydrograph charting module', () => {
                 },
                 title: 'My Title',
                 desc: 'My Description',
+                showMedianStatsLabel: false,
                 width: 400
             });
             select(graphNode)
@@ -145,12 +147,19 @@ describe('Hydrograph charting module', () => {
 
         it('should have a point for the median stat data with a label', () => {
             expect(selectAll('svg circle#median-point').size()).toBe(1);
-            expect(selectAll('svg text#median-text').size()).toBe(1);
+            expect(selectAll('svg text#median-text').size()).toBe(0);
         });
 
         it('should have a legend with two markers', () => {
            expect(selectAll('g.legend-marker').size()).toBe(2);
         });
+
+        it('show show the labels for the median stat data showMedianStatsLabel is true', () => {
+            store.dispatch(Actions.showMedianStatsLabel(true));
+
+            expect(selectAll('svg text#median-text').size()).toBe(1);
+
+        });
     });
 
     describe('Hydrograph tooltips', () => {
diff --git a/assets/src/scripts/components/hydrograph/store.spec.js b/assets/src/scripts/components/hydrograph/store.spec.js
index 6030942e4..aa3141a62 100644
--- a/assets/src/scripts/components/hydrograph/store.spec.js
+++ b/assets/src/scripts/components/hydrograph/store.spec.js
@@ -1,5 +1,4 @@
 const { Actions, timeSeriesReducer } = require('./store');
-const { lineMarker, circleMarker } = require('./markers');
 
 
 describe('Redux store', () => {
@@ -39,6 +38,21 @@ describe('Redux store', () => {
                 medianStatistics: 'statsData'
             });
         });
+
+        it('should create an action to show the median stats label', () => {
+            expect(Actions.showMedianStatsLabel(true)).toEqual({
+                type: 'SHOW_MEDIAN_STATS_LABEL',
+                show: true
+            });
+
+        });
+
+        it('should create an action to resize plot', () => {
+            expect(Actions.resizeTimeseriesPlot(100)).toEqual({
+                type: 'RESIZE_TIMESERIES_PLOT',
+                width: 100
+            });
+        });
     });
 
     describe('reducers', () => {
@@ -112,5 +126,23 @@ describe('Redux store', () => {
                 }
             });
         });
+
+        it('should handle SHOW_MEDIAN_STATS_LABEL', () => {
+            expect(timeSeriesReducer({}, {
+                type: 'SHOW_MEDIAN_STATS_LABEL',
+                show: true
+            })).toEqual({
+                showMedianStatsLabel: true
+            });
+        });
+
+        it('should handle RESIZE_TIMESERIES_PLOT', () => {
+            expect(timeSeriesReducer({}, {
+                type: 'RESIZE_TIMESERIES_PLOT',
+                width: 100
+            })).toEqual({
+                width: 100
+            });
+        });
     });
 });
-- 
GitLab