Skip to content
Snippets Groups Projects
Commit 4cb59428 authored by Williams, Darius Shamar's avatar Williams, Darius Shamar
Browse files

tests, lint

parent c0cd8497
No related branches found
No related tags found
1 merge request!320Wdfn 736 - Adding statistical data to the ML pages
......@@ -304,7 +304,7 @@ describe('monitoring-location/components/hydrograph module', () => {
hydrographParameterSelectors.latestSelectedParameterValue = jest.fn().mockReturnValue(() => {
return function() {
return 123;
}
};
});
linkSpy = jest.spyOn(d3Redux, 'link');
attachToNode(store, graphNode, {
......
......@@ -7,6 +7,7 @@ import * as utils from 'ui/utils';
import {configureStore} from 'ml/store';
import * as hydrographData from 'ml/store/hydrograph-data';
import * as hydrographState from 'ml/store/hydrograph-state';
import * as dataIndicator from './data-indicator';
import {TEST_HYDROGRAPH_PARAMETERS} from './mock-hydrograph-state';
......@@ -54,6 +55,8 @@ describe('monitoring-location/components/hydrograph/parameters module', () => {
let store;
let retrieveHydrographDataSpy;
let showDataIndicatorSpy;
let clearChangedParameterFlagSpy;
let restoreConsole;
beforeAll(() => {
......@@ -70,6 +73,7 @@ describe('monitoring-location/components/hydrograph/parameters module', () => {
div = select('body').append('div');
retrieveHydrographDataSpy = jest.spyOn(hydrographData, 'retrieveHydrographData');
showDataIndicatorSpy = jest.spyOn(dataIndicator, 'showDataIndicators');
clearChangedParameterFlagSpy = jest.spyOn(hydrographState, 'clearChangedParameterFlag');
});
afterEach(() => {
......@@ -115,14 +119,16 @@ describe('monitoring-location/components/hydrograph/parameters module', () => {
});
});
it('Expects changing the selection clears the changing parameter flag', () => {
it('Expects changing the selection clears the changing parameter flag', async() => {
store = configureStore(TEST_STATE);
drawSelectionList(div, store, '11112222', 'USGS');
const rowOne = div.select('#container-row-00060');
rowOne.dispatch('click');
//TODO: fix this and make tests for the dispatch action
expect(store.getState().hydrographState.parameterCodeChanged).toBe(false);
// eslint-disable-next-line no-undef
await new Promise((promise) => setTimeout(promise, 2000));
expect(clearChangedParameterFlagSpy).toHaveBeenCalled();
});
it('Expects that the row for the selected parameter will be open when the page loads', function() {
......
......@@ -14,7 +14,7 @@ export const getDailyStatistics = memoize( (date) => createSelector(
(stats) => {
if (!stats || !Object.keys(stats).length) {
return {}
return {};
}
let statsData = stats[Object.keys(stats)[0]];
......
......@@ -15,7 +15,7 @@ describe('monitoring-location/components/hydrograph/selectors/statistics-table',
describe('getDailyStatistics', () => {
it('Returns empty object if no stats data exists', () => {
expect(getDailyStatistics(new Date(2020,0,1))({
expect(getDailyStatistics(new Date(2020, 0, 1))({
...TEST_STATE,
hydrographData: {
statisticsData: {}
......@@ -25,7 +25,7 @@ describe('monitoring-location/components/hydrograph/selectors/statistics-table',
});
it('Returns data object of correct day', () => {
expect(getDailyStatistics(new Date(2020,0,2))({
expect(getDailyStatistics(new Date(2020, 0, 2))({
...TEST_STATE,
hydrographData: {
statisticsData: TEST_STATS_DATA
......@@ -54,7 +54,7 @@ describe('monitoring-location/components/hydrograph/selectors/statistics-table',
});
it('Returns array index of correct day on leap years', () => {
expect(getDailyStatistics(new Date(2020,2,1))({
expect(getDailyStatistics(new Date(2020, 2, 1))({
...TEST_STATE,
hydrographData: {
statisticsData: {
......@@ -65,7 +65,7 @@ describe('monitoring-location/components/hydrograph/selectors/statistics-table',
});
it('Returns array index of correct day on non-leap years', () => {
expect(getDailyStatistics(new Date(2021,2,1))({
expect(getDailyStatistics(new Date(2021, 2, 1))({
...TEST_STATE,
hydrographData: {
statisticsData: {
......
......@@ -50,7 +50,7 @@ const clearNonStatsHydrographData = function() {
return {
type: 'CLEAR_NON_STATS_HYDROGRAPH_DATA'
};
}
};
/*
* Synchronous Redux action which sets the IV data for the dataKind
......
......@@ -11,7 +11,7 @@ export const INITIAL_STATE = {
selectedIVMethodID: null,
graphCursorOffset: null,
graphBrushOffset: null,
parameterCodeChanged: true
parameterCodeChanged: null
};
/*
......@@ -120,8 +120,8 @@ export const clearGraphBrushOffset = function() {
export const clearChangedParameterFlag = function() {
return {
type: 'CLEAR_CHANGED_PARAMETER_FLAG'
}
}
};
};
export const hydrographStateReducer = function(hydrographState = INITIAL_STATE, action) {
let hasIVData;
......
......@@ -109,6 +109,32 @@ describe('monitoring-location/store/hydrograph-state', () => {
expect(state.selectedParameterCode).toBe('62611');
expect(state.selectedTimeSpan).toBe('periodOfRecord');
});
it('sets the changed parameter flag to true if the action parameter code is different from the state parameter code', () => {
store.dispatch(setSelectedParameterCode('00060'));
const state = store.getState().hydrographState;
expect(state.parameterCodeChanged).toBe(true);
});
it('sets the changed parameter flag to false if the action parameter code is not different from the state parameter code', () => {
store = createStore(
combineReducers({
hydrographState: hydrographStateReducer
}),
{
hydrographState: {
...INITIAL_STATE,
selectedParameterCode: '00060'
}
},
applyMiddleware(thunk)
);
store.dispatch(setSelectedParameterCode('00060'));
const state = store.getState().hydrographState;
expect(state.parameterCodeChanged).toBe(false);
});
});
describe('setSelectedIVMethodID', () => {
......
......@@ -124,7 +124,8 @@ body {
.wdfn-accordion {
//Override the default uswds margin for adjacent accordion components
margin-top: 1rem !important;
// margin-top: 1rem !important;
@include uswds.u-margin-top(2);
.usa-accordion-content {
overflow: visible;
}
......
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