diff --git a/CHANGELOG.md b/CHANGELOG.md index bfd44c8e45616f2d9be4eb4f7c4dbc0b7f3a65a4..80f61a1acd00dec2dad32d04f6c47cbd73425983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Data tables accordion shows a table for a secondary instantaneous value parameter data when a second parameter (that has data) is selected. - Retrieve data controls now show a radio button for secondary parameter data when appropriate. - Title, legend and time series data line will now show for a secondary parameter, if selected. +- Main hydrograph tool tips now reflect the data points for secondary parameter lines. ### Changed - Data download component was converted to Vue. diff --git a/assets/src/scripts/d3-rendering/axes.test.js b/assets/src/scripts/d3-rendering/axes.test.js index 0c91595140268fbd282673306acc8d50f4427126..5ad618595575e2946ed6115df3e8e332e605e476 100644 --- a/assets/src/scripts/d3-rendering/axes.test.js +++ b/assets/src/scripts/d3-rendering/axes.test.js @@ -96,7 +96,24 @@ describe('axes module', () => { expect(svg.select('.secondary-y-axis .y-axis-label').html()).toBe('ft/3'); }); - it('should render only one y axis if a secondaryYAxis is not defined', () => { + it('expects that secondary axis is removed if a secondary parameter is no longer defined', () => { + secondaryYAxis = jest.fn(); + appendAxes(svg, {xAxis, primaryYAxis, secondaryYAxis, layout, primaryYTitle: 'ft', secondaryYTitle: 'ft/3', secondaryParameter}); + + expect(svg.selectAll('.x-axis').size()).toBe(1); + expect(svg.selectAll('.y-axis').size()).toBe(1); + expect(svg.selectAll('.secondary-y-axis').size()).toBe(1); + expect(svg.selectAll('.y-axis-label').size()).toBe(2); + expect(svg.select('.y-axis .y-axis-label').html()).toBe('ft'); + expect(svg.select('.secondary-y-axis .y-axis-label').html()).toBe('ft/3'); + + appendAxes(svg, {xAxis, primaryYAxis, layout, primaryYTitle: 'ft'}); + expect(svg.selectAll('.x-axis').size()).toBe(1); + expect(svg.selectAll('.y-axis').size()).toBe(1); + expect(svg.selectAll('.secondary-y-axis').size()).toBe(0); + }); + + it('should render only one y-axis if a secondaryYAxis is not defined', () => { appendAxes(svg, {xAxis, primaryYAxis, secondaryYAxis, layout, primaryYTitle: 'ft', secondaryYTitle: '', secondaryParameter: null}); expect(svg.selectAll('.x-axis').size()).toBe(1); diff --git a/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.test.js b/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.test.js index 49132aab87da290f0ad74d545dced319fd3303ee..5d6d75deff9d715bcc512418f91fe274d5364839 100644 --- a/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.test.js +++ b/assets/src/scripts/monitoring-location/components/hydrograph/tooltip.test.js @@ -5,7 +5,7 @@ import * as utils from 'ui/utils'; import {configureStore} from 'ml/store'; -import {TEST_GW_LEVELS, TEST_PRIMARY_IV_DATA, TEST_CURRENT_TIME_RANGE} from './mock-hydrograph-state'; +import {TEST_GW_LEVELS, TEST_PRIMARY_IV_DATA, TEST_SECONDARY_IV_DATA, TEST_CURRENT_TIME_RANGE} from './mock-hydrograph-state'; import {drawTooltipText, drawTooltipFocus, drawTooltipCursorSlider, initializeTooltipCursorSlider} from './tooltip'; describe('monitoring-location/components/hydrograph/tooltip module', () => { @@ -59,8 +59,42 @@ describe('monitoring-location/components/hydrograph/tooltip module', () => { value = div.select('.gw-level-point').text().split(' - ')[0]; expect(value).toBe('27.2 ft'); }); + + it('expects that if a secondary parameter is graphed that it will have a tool tip', () => { + const TEST_STATE_SECONDARY_PARAMETER = { + hydrographData: { + primaryIVData: TEST_PRIMARY_IV_DATA, + secondaryIVData: TEST_SECONDARY_IV_DATA, + currentTimeRange: TEST_CURRENT_TIME_RANGE + }, + groundwaterLevelData: { + all: [TEST_GW_LEVELS] + }, + hydrographState: { + selectedIVMethodID: '90649', + graphCursorOffset: 500000, + selectedParameterCode: '72019', + selectedSecondaryParameterCode: '00065' + }, + ui: { + windowWidth: 1300, + width: 990 + } + }; + + store = configureStore(TEST_STATE_SECONDARY_PARAMETER); + + div.call(drawTooltipText, store); + expect(div.select('.primary-tooltip-text').size()).toBe(1); + expect(div.select('.primary-tooltip-text').text()).toBe('24.1 ft - Feb 24, 2020 10:30:00 AM CST'); + + expect(div.select('.secondary-tooltip-text').size()).toBe(1); + expect(div.select('.secondary-tooltip-text').text()).toBe('3.2 ft - Feb 24, 2020 10:30:00 AM CST'); + }); }); + describe('createTooltipFocus', () => { + let store; let svg; beforeEach(() => { svg = select('body').append('svg'); @@ -71,7 +105,7 @@ describe('monitoring-location/components/hydrograph/tooltip module', () => { }); it('Creates focus lines and focus circles when cursor not set', () => { - let store = configureStore(TEST_STATE); + store = configureStore(TEST_STATE); svg.call(drawTooltipFocus, store); @@ -79,6 +113,38 @@ describe('monitoring-location/components/hydrograph/tooltip module', () => { expect(svg.selectAll('.focus-circle').size()).toBe(2); expect(svg.select('.focus-overlay').size()).toBe(1); }); + + + it('expects that if a secondary parameter is graphed that it will have a focus dot', () => { + const TEST_STATE_SECONDARY_PARAMETER = { + hydrographData: { + primaryIVData: TEST_PRIMARY_IV_DATA, + secondaryIVData: TEST_SECONDARY_IV_DATA, + currentTimeRange: TEST_CURRENT_TIME_RANGE + }, + groundwaterLevelData: { + all: [TEST_GW_LEVELS] + }, + hydrographState: { + selectedIVMethodID: '90649', + graphCursorOffset: 500000, + selectedParameterCode: '72019', + selectedSecondaryParameterCode: '00065' + }, + ui: { + windowWidth: 1300, + width: 990 + } + }; + + store = configureStore(TEST_STATE_SECONDARY_PARAMETER); + + svg.call(drawTooltipFocus, store); + + expect(svg.selectAll('.focus-line').size()).toBe(1); + expect(svg.selectAll('.focus-circle').size()).toBe(3); + expect(svg.select('.focus-overlay').size()).toBe(1); + }); }); describe('initializeTooltipCursorSlider and drawTooltipCursorSlider', () => {