diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.test.js index 7f5f65f831b58200c078f8d674c89b0217e10a09..224869ece9d8acfc9f46bf408dab0798c89e0374 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/vue-components/download-data.test.js @@ -2,14 +2,15 @@ import config from 'ui/config'; import {configureStore} from 'ml/store'; -import {setCompareDataVisibility, setMedianDataVisibility} from 'ml/store/hydrograph-state'; +import {setCompareDataVisibility, setMedianDataVisibility, setSecondaryIVDataVisibility} from 'ml/store/hydrograph-state'; import { TEST_CURRENT_TIME_RANGE, TEST_COMPARE_TIME_RANGE, TEST_PRIMARY_IV_DATA, TEST_STATS_DATA, - TEST_GW_LEVELS + TEST_GW_LEVELS, + TEST_SECONDARY_IV_DATA } from '../mock-hydrograph-state'; import {mount} from '@vue/test-utils'; @@ -31,6 +32,7 @@ describe('monitoring-location/components/hydrograph/vue-components/download-data currentTimeRange: TEST_CURRENT_TIME_RANGE, prioryearTimeRange: TEST_COMPARE_TIME_RANGE, primaryIVData: TEST_PRIMARY_IV_DATA, + secondaryIVData: TEST_SECONDARY_IV_DATA, compareIVData: TEST_PRIMARY_IV_DATA, statisticsData: TEST_STATS_DATA }, @@ -40,7 +42,9 @@ describe('monitoring-location/components/hydrograph/vue-components/download-data hydrographState: { showCompareIVData: false, showMedianData: false, + showSecondaryIVData: false, selectedIVMethodID: '90649', + selectedSecondaryIVMethodID: '57465', selectedParameterCode: '72019' } }; @@ -86,6 +90,8 @@ describe('monitoring-location/components/hydrograph/vue-components/download-data expect(wrapper.findAll('input[type="radio"]')).toHaveLength(4); await store.dispatch(setMedianDataVisibility(true)); expect(wrapper.findAll('input[type="radio"]')).toHaveLength(5); + await store.dispatch(setSecondaryIVDataVisibility(true)); + expect(wrapper.findAll('input[type="radio"]')).toHaveLength(6); }); it('Shows an error message if the download button is clicked with no radio buttons checked', async() => { @@ -149,6 +155,20 @@ describe('monitoring-location/components/hydrograph/vue-components/download-data expect(windowSpy.mock.calls[0][0]).toContain('endDT=2013-06-13T15:57:44.000-05:00'); }); + it('Opens window for secondary parameter data when selected and downloaded', async() => { + const downloadButton = wrapper.find('button.download-selected-data'); + await store.dispatch(setSecondaryIVDataVisibility(true)); + + const compareDataButton = wrapper.find('#test-buttons-secondary-data-download-button'); + await compareDataButton.trigger('click'); + await downloadButton.trigger('click'); + expect(windowSpy.mock.calls[0][0]).toContain('/iv/'); + expect(windowSpy.mock.calls[0][0]).toContain('sites=11112222'); + expect(windowSpy.mock.calls[0][0]).toContain('parameterCd=00065&'); + expect(windowSpy.mock.calls[0][0]).toContain('startDT=2020-02-24T10:15:00.000-06:00'); + expect(windowSpy.mock.calls[0][0]).toContain('endDT=2020-09-20T11:45:00.000-05:00'); + }); + it('Expects the error alert to disappear once a user selects a radio', async() => { const downloadButton = wrapper.find('button.download-selected-data'); await downloadButton.trigger('click');