[fix] should set chartUpdateEndTime when chart fetch failed or stopped (#6205)

This commit is contained in:
Grace Guo
2018-10-26 15:00:03 -07:00
committed by GitHub
parent 5c02e3199b
commit dcf048c52e
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import chartReducer, { chart } from '../../../src/chart/chartReducer';
import * as actions from '../../../src/chart/chartAction';
describe('chart reducers', () => {
const chartKey = 1;
let testChart;
let charts;
beforeEach(() => {
testChart = {
...chart,
id: chartKey,
};
charts = { [chartKey]: testChart };
});
it('should update endtime on fail', () => {
const newState = chartReducer(charts, actions.chartUpdateStopped(chartKey));
expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0);
expect(newState[chartKey].chartStatus).toEqual('stopped');
});
it('should update endtime on timeout', () => {
const newState = chartReducer(charts, actions.chartUpdateTimeout('timeout', 60, chartKey));
expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0);
expect(newState[chartKey].chartStatus).toEqual('failed');
});
});