diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/mock-hydrograph-state.js b/assets/src/scripts/monitoring-location/components/hydrograph/mock-hydrograph-state.js index cdb613fc691d8e1351e54da33a97e0977644ec0d..5c48d4ae2a77a7465f77a373d0a4bcba0085e9eb 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/mock-hydrograph-state.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/mock-hydrograph-state.js @@ -67,6 +67,16 @@ export const TEST_SECONDARY_IV_DATA = { methodID: '57465', methodDescription: '' } + }, + '69929': { + points: [ + {value: '3', qualifiers: ['A'], dateTime: 1582560900000}, + {value: '3.2', qualifiers: ['A'], dateTime: 1582561800000} + ], + method: { + methodID: '69929', + methodDescription: '' + } } } }; diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js index 4466684197a52f2061c1d348b98774a92646cbce..dbc9e55de4ac16dd48520e54da3ace00cd25ec3f 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/selectors/time-series-data.test.js @@ -1,6 +1,6 @@ import config from 'ui/config'; -import {TEST_PRIMARY_IV_DATA, TEST_STATS_DATA, TEST_GW_LEVELS} from '../mock-hydrograph-state'; +import {TEST_PRIMARY_IV_DATA, TEST_SECONDARY_IV_DATA, TEST_STATS_DATA, TEST_GW_LEVELS} from '../mock-hydrograph-state'; import { isVisible, hasVisibleIVData, hasVisibleGroundwaterLevels, hasVisibleMedianStatisticsData, hasAnyVisibleData, getTitle, getDescription, getPrimaryParameterUnitCode, getPreferredIVMethodID, getSortedIVMethods, @@ -56,6 +56,34 @@ const TEST_STATE = { } } } + }, + +secondaryIVData: { + parameter: { + parameterCode:'00030', + name: 'Dissolved oxygen, water, unfiltered, mg/L', + description: 'Dissolved oxygen, water, unfiltered, milligrams per liter', + unit: 'mg/l' + }, + values: { + '69937': { + points: [], + method: { + methodDescription: 'From multiparameter sonde, [Discontinued]', + methodID: '69937' + } + }, + '252055': { + points: [ + {value: '100', qualifiers: ['P'], dateTime: 1613569918467}, + {value: '1', qualifiers: ['p'], dateTime: 1614174718455} + ], + method: { + methodDescription: 'From multiparameter sonde', + methodID: '252055' + } + } + } } }, groundwaterLevelData: { @@ -575,41 +603,20 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m expect(result.methods[1].methodID).toBe('252055'); expect(result.methods[2].methodID).toBe('69937'); }); - it('If there is not a sampling method description, the method id will be used', () => { - const result = getSortedIVMethods('primary')({ + + it('expects if the dataKind is secondary, it will return sorted secondary methods', () => { + const result = getSortedIVMethods('secondary')({ hydrographData: { ...TEST_STATE.hydrographData, - primaryIVData: { - ...TEST_STATE.hydrographData.primaryIVData, - values: { - ...TEST_STATE.hydrographData.primaryIVData.values, - '152088': { - points: [ - {value: '25.1'}, - {value: '26.1'}, - {value: '27.1'} - ], - method: { - methodDescription: '', - methodID: '152088' - } - } - } - } - }, - groundwaterLevelData: { - all: [] + primaryIVData: TEST_PRIMARY_IV_DATA, + secondaryIVData: TEST_SECONDARY_IV_DATA } }); - expect(result.methods[0]['methodDescription']).toBe('152088'); - expect(result.methods[1]['methodDescription']).toBe('From multiparameter sonde'); - expect(result.methods[2]['methodDescription']).toBe('From multiparameter sonde, [Discontinued]'); + expect(result.methods[0]['methodDescription']).toBe('57465'); + expect(result.methods[1]['methodDescription']).toBe('69929'); }); }); - - - describe('getSelectedMethodDescription', () => { it('Returns the method description of the selected method', () => { const result = getSelectedMethodDescription(TEST_STATE); diff --git a/assets/src/scripts/monitoring-location/selectors/hydrograph-state-selector.test.js b/assets/src/scripts/monitoring-location/selectors/hydrograph-state-selector.test.js index 28cb3db7e37ca4c735a45de1e775e3f18c247e4f..6156688f328aa2edc4aafeca94cb84dd1f2b3636 100644 --- a/assets/src/scripts/monitoring-location/selectors/hydrograph-state-selector.test.js +++ b/assets/src/scripts/monitoring-location/selectors/hydrograph-state-selector.test.js @@ -1,7 +1,7 @@ import config from 'ui/config'; import {isCompareIVDataVisible, isSecondaryIVDataVisible, isMedianDataVisible, getSelectedTimeSpan, getSelectedParameterCode, - getSelectedIVMethodID, getGraphCursorOffset, getGraphBrushOffset, getInputsForRetrieval + getSelectedIVMethodID, getSelectedSecondaryIVMethodID, getGraphCursorOffset, getGraphBrushOffset, getInputsForRetrieval } from './hydrograph-state-selector'; describe('monitoring-location/selectors/hydrograph-state-selector', () => { @@ -86,6 +86,22 @@ describe('monitoring-location/selectors/hydrograph-state-selector', () => { }); }); + describe('getSecondarySelectedIVMethodID', () => { + it('Returns null if no second parameter has been selected', () => { + expect(getSelectedSecondaryIVMethodID({ + hydrographState: {} + })).toBeNull(); + }); + + it('Returns selected secondary IV method id', () => { + expect(getSelectedSecondaryIVMethodID({ + hydrographState: { + selectedSecondaryIVMethodID: '69929' + } + })).toEqual('69929'); + }); + }); + describe('getGraphCursorOffset', () => { it('Returns null if no graph cursor offset', () => { expect(getGraphCursorOffset({ diff --git a/assets/src/scripts/monitoring-location/store/hydrograph-state.test.js b/assets/src/scripts/monitoring-location/store/hydrograph-state.test.js index 11d144fed230d95ef788458e978cb944f8f1cd8d..2983d57ce85066b4e101b49b20918dc773f540ca 100644 --- a/assets/src/scripts/monitoring-location/store/hydrograph-state.test.js +++ b/assets/src/scripts/monitoring-location/store/hydrograph-state.test.js @@ -4,8 +4,8 @@ import {default as thunk} from 'redux-thunk'; import config from 'ui/config'; import {INITIAL_STATE, setCompareDataVisibility, setMedianDataVisibility, setSelectedParameterCode, - setSelectedIVMethodID, setSelectedTimeSpan, setGraphCursorOffset, setGraphBrushOffset, clearGraphBrushOffset, - hydrographStateReducer + setSelectedIVMethodID, setSelectedSecondaryIVMethodID, setSelectedTimeSpan, setGraphCursorOffset, + setGraphBrushOffset, clearGraphBrushOffset, hydrographStateReducer } from './hydrograph-state'; describe('monitoring-location/store/hydrograph-state', () => { @@ -44,6 +44,13 @@ describe('monitoring-location/store/hydrograph-state', () => { }); }); + describe('setSelectedSecondaryIVMethodID', () => { + it('sets the id of the secondary parameter method', () => { + store.dispatch(setSelectedSecondaryIVMethodID ('69929')); + expect(store.getState().hydrographState.selectedSecondaryIVMethodID).toBe('69929'); + }); + }); + describe('setSelectedParameterCode', () => { config.ivPeriodOfRecord = { '00060' : {