Skip to content
Snippets Groups Projects
Commit 5f72fd06 authored by Bucknell, Mary S.'s avatar Bucknell, Mary S.
Browse files

All tests are now working. the download-links module tests were completely...

All tests are now working. the download-links module tests were completely revamp since the UI works in a very different way now.
parent 4dd92c99
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ import {DateTime} from 'luxon';
import {createStructuredSelector} from 'reselect';
import config from 'ui/config.js';
import{link} from 'ui/lib/d3-redux';
import {link} from 'ui/lib/d3-redux';
import {getIVServiceURL, getSiteMetaDataServiceURL} from 'ui/web-services/instantaneous-values';
import {getStatisticsServiceURL} from 'ui/web-services/statistics-data';
import {getGroundwaterServiceURL} from 'ui/web-services/groundwater-levels';
......@@ -29,8 +29,8 @@ const getIVDataURL = function(store, siteno, timeRangeKind) {
return getIVServiceURL({
siteno,
parameterCode: getPrimaryParameter(currentState).parameterCode,
startDT: toISO(timeRange.start),
endDT: toISO(timeRange.end),
startTime: toISO(timeRange.start),
endTime: toISO(timeRange.end),
format: 'rdb'
});
};
......@@ -102,6 +102,13 @@ const drawCheckboxes = function(container, {
checkboxContainer.call(drawCheckbox, 'download-site-meta-data', 'About this location', 'site');
};
/*
* Render the download form and set up all appropriate even handlers. The checkboxes drawn are tied to what data is currently
* visible on the hydrograph.
* @param {D3 selection} container
* @param {Redux store} store
* @param {String} siteno
*/
export const drawDownloadForm = function(container, store, siteno) {
const formContainer = container.append('form')
.attr('class', 'usa-form')
......
......@@ -129,7 +129,6 @@ export const attachToNode = function(store,
nodeElem.select('#hydrograph-method-picker-container')
.call(drawMethodPicker, store);
legendControlsContainer.call(drawGraphControls, store, siteno);
nodeElem.select('.select-actions-container').call(drawSelectActions, store, siteno);
......
......@@ -41,7 +41,7 @@ describe('monitoring-location/components/hydrograph module', () => {
}
};
config.igwPeriodOfRecord = {
config.gwPeriodOfRecord = {
'72019': {
begin_date: '01-02-2000',
end_date: '10-15-2015'
......@@ -66,13 +66,12 @@ describe('monitoring-location/components/hydrograph module', () => {
.attr('href', 'https://fakeserver/link');
let component = body.append('div')
.attr('id', 'hydrograph');
component.append('div').attr('id', 'hydrograph-date-controls-container');
component.append('div').attr('id', 'hydrograph-method-picker-container');
component.append('div').attr('class', 'graph-container')
.append('div')
.attr('id', 'hydrograph-loading-indicator-container')
.attr('class', 'loading-indicator-container');
component.append('div').attr('class', 'select-actions-container');
component.append('div').attr('class', 'select-time-series-container');
component.append('div').attr('id', 'iv-data-table-container');
......@@ -315,9 +314,8 @@ describe('monitoring-location/components/hydrograph module', () => {
expect(selectAll('.cursor-slider-svg').size()).toBe(1);
});
it('should have date control elements', () => {
expect(selectAll('#ts-daterange-select-container').size()).toBe(1);
expect(selectAll('#ts-customdaterange-select-container').size()).toBe(1);
it('should have date control form', () => {
expect(selectAll('#change-time-span-container').size()).toBe(1);
});
it('should have method select element', () => {
......
......@@ -58,7 +58,7 @@ export const hasVisibleMedianStatisticsData = createSelector(
export const hasVisibleGroundwaterLevels = createSelector(
getGroundwaterLevels,
(gwLevels) => gwLevels && gwLevels.values && gwLevels.values.length
gwLevels => gwLevels && gwLevels.values ? gwLevels.values.length > 0 : false
);
/*
......
......@@ -2,8 +2,8 @@ import config from 'ui/config';
import {TEST_PRIMARY_IV_DATA, TEST_MEDIAN_DATA, TEST_GW_LEVELS} from '../mock-hydrograph-state';
import {
isVisible, hasAnyVisibleData, getTitle, getDescription, getPrimaryParameterUnitCode,
getPreferredIVMethodID
isVisible, hasVisibleIVData, hasVisibleGroundwaterLevels, hasVisibleMedianStatisticsData, hasAnyVisibleData,
getTitle, getDescription, getPrimaryParameterUnitCode, getPreferredIVMethodID
}
from './time-series-data';
......@@ -70,7 +70,103 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m
});
});
describe('hasVisibleData', () => {
describe('hasVisibleIVData', () => {
it('return false if no data exists', () => {
expect(hasVisibleIVData('primary')({
hydrographData: {},
hydrographState: {}
})).toBe(false);
});
it('Return false if data has been selected but no data exists', () => {
expect(hasVisibleIVData('compare')(TEST_STATE)).toBe(false);
});
it('return true if data is selected and visible', () => {
expect(hasVisibleIVData('primary')(TEST_STATE)).toBe(true);
});
it('Return false if data is selected but no data points are available', () => {
expect(hasVisibleIVData('primary')({
...TEST_STATE,
hydrographState: {
...TEST_STATE.hydrographState,
selectedIVMethodID: '69937'
}
})).toBe(false);
});
});
describe('hasVisibleMedianStatisticsData', () => {
it('Return false if no data is available', () => {
expect(hasVisibleMedianStatisticsData({
hydrographData: {},
hydrographState: {}
})).toBe(false);
});
it('Return false if median data is available for not selected for display', () => {
expect(hasVisibleMedianStatisticsData({
hydrographData: {
medianStatisticsData: TEST_MEDIAN_DATA
},
hydrographState: {
showMedianData: false
}
})).toBe(false);
});
it('Return false if no median data is available and but is selected for display', () => {
expect(hasVisibleMedianStatisticsData({
hydrographData: {
medianStatisticsData: {}
},
hydrographState: {
showMedianData: true
}
})).toBe(false);
});
it('return true if median data is available and it is selected for display', () => {
expect(hasVisibleMedianStatisticsData({
hydrographData: {
medianStatisticsData: TEST_MEDIAN_DATA
},
hydrographState: {
showMedianData: true
}
})).toBe(true);
});
});
describe('hasVisibleGroundwaterLevels', () => {
it('Return false if no data is available', () => {
expect(hasVisibleGroundwaterLevels({
hydrographData: {}
})).toBe(false);
});
it('Return false if the data contains no points', () => {
expect(hasVisibleGroundwaterLevels({
hydrographData: {
groundwaterLevels: {
...TEST_GW_LEVELS,
values: []
}
}
})).toBe(false);
});
it('Return true if the data contains points', () => {
expect(hasVisibleGroundwaterLevels({
hydrographData: {
groundwaterLevels: TEST_GW_LEVELS
}
})).toBe(true);
});
});
describe('hasAnyVisibleData', () => {
it('Expects to return true when data is available and visible', () => {
expect(hasAnyVisibleData({
hydrographData: {
......@@ -245,7 +341,7 @@ describe('monitoring-location/components/hydrograph/selectors/time-series-data m
hydrographData: {
primaryIVData: {
parameter: {
parameterCode: '00030',
parameterCode: '00030'
},
values: {}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment