From 8b25d8a7801a10b7723b58b046eedd489798defa Mon Sep 17 00:00:00 2001 From: Ran Byron Date: Sun, 13 Jan 2019 15:05:15 +0200 Subject: [PATCH] Rebased to master --- .../components/queries/ScheduleDialog.test.js | 76 +++---------------- 1 file changed, 12 insertions(+), 64 deletions(-) diff --git a/client/app/components/queries/ScheduleDialog.test.js b/client/app/components/queries/ScheduleDialog.test.js index beb9730fb7..cb0fc8ee2b 100644 --- a/client/app/components/queries/ScheduleDialog.test.js +++ b/client/app/components/queries/ScheduleDialog.test.js @@ -37,26 +37,6 @@ function findByTestID(wrapper, id) { return wrapper.find(`[data-testid="${id}"]`); } -function getSelectOptions(wrapper) { - jest.useFakeTimers(); - - // click select - wrapper.find('.ant-select').simulate('click'); - - // run timers - jest.runAllTimers(); - jest.useRealTimers(); - - // get dropdown menu - const dropdown = mount(wrapper - .find('Trigger') - .instance() - .getComponent()); - - // get menu items - return dropdown.find('MenuItem'); -} - describe('ScheduleDialog', () => { describe('Sets correct schedule settings', () => { test('Sets to "Never"', () => { @@ -134,28 +114,23 @@ describe('ScheduleDialog', () => { describe('Adheres to user permissions', () => { test('Shows correct interval options', () => { - const refreshOptions = [60, 3600]; // 1 min, 1 hour + const refreshOptions = [60, 300, 3600, 7200]; // 1 min, 1 hour const [wrapper] = getWrapper(null, { refreshOptions }); - const selectWrapper = findByTestID(wrapper, 'select-interval'); - const options = getSelectOptions(selectWrapper); - const texts = options.map(node => node.text()); - const expected = ['Never', 'minute(s)', 'hour(s)']; - - // eslint-disable-next-line jest/prefer-to-have-length - expect(options.length).toEqual(expected.length); - expect(texts).toEqual(expected); - }); + // click select + findByTestID(wrapper, 'interval') + .find('.ant-select') + .simulate('click'); - // skipped due to issue #3263 https://git.io/fhZcG - // eslint-disable-next-line jest/no-disabled-tests - test.skip('Shows correct count options', () => { - const [wrapper] = getWrapper({ interval: 300 }); - const selectWrapper = findByTestID(wrapper, 'select-count'); - const options = getSelectOptions(selectWrapper); + // get dropdown menu items + const options = mount(wrapper + .find('Trigger') + .instance() + .getComponent()) + .find('MenuItem'); const texts = options.map(node => node.text()); - const expected = ['1', '5', '10']; + const expected = ['Never', '1 minute', '5 minutes', '1 hour', '2 hours']; // eslint-disable-next-line jest/prefer-to-have-length expect(options.length).toEqual(expected.length); @@ -163,33 +138,6 @@ describe('ScheduleDialog', () => { }); }); - test('Resets selected count value if out-of-range', () => { - // init - const initProps = { interval: 600 }; - const [wrapper] = getWrapper(initProps); - - const intervalWrapper = findByTestID(wrapper, 'select-interval'); - const options = getSelectOptions(intervalWrapper); - - // change to 'hours(s)' - options - .filterWhere(node => node.text() === 'hour(s)') - .simulate('click'); - wrapper.update(); - - // should stay '10' - expect(wrapper.state('count')).toBe('10'); - - // change to 'week(s)' - options - .filterWhere(node => node.text() === 'week(s)') - .simulate('click'); - wrapper.update(); - - // should have changed to '1' - expect(wrapper.state('count')).toBe('1'); - }); - describe('Modal Confirm/Cancel feature', () => { const confirmCb = jest.fn().mockName('confirmCb'); const closeCb = jest.fn().mockName('closeCb');