feat: [dashboard] notification and warning for auto force refresh (#9886)

* feat: [dashboard] notification and warning for auto force refresh

* fix review comments
This commit is contained in:
Grace Guo
2020-06-03 10:20:56 -07:00
committed by GitHub
parent ee777acd57
commit dcac860f3e
13 changed files with 156 additions and 6 deletions

View File

@@ -17,9 +17,11 @@
* under the License.
*/
import React from 'react';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import ModalTrigger from 'src/components/ModalTrigger';
import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal';
import { Modal, Alert } from 'react-bootstrap';
describe('RefreshIntervalModal', () => {
const mockedProps = {
@@ -44,7 +46,22 @@ describe('RefreshIntervalModal', () => {
it('should change refreshFrequency with edit mode', () => {
const wrapper = mount(<RefreshIntervalModal {...mockedProps} />);
wrapper.instance().handleFrequencyChange({ value: 30 });
wrapper.instance().onSave();
expect(mockedProps.onChange).toHaveBeenCalled();
expect(mockedProps.onChange).toHaveBeenCalledWith(30, mockedProps.editMode);
});
it('should show warning message', () => {
const props = {
...mockedProps,
refreshLimit: 3600,
refreshWarning: 'Show warning',
};
const wrapper = shallow(<RefreshIntervalModal {...props} />);
wrapper.instance().handleFrequencyChange({ value: 30 });
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(1);
wrapper.instance().handleFrequencyChange({ value: 3601 });
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(0);
});
});