From 2bc75207c644d51426c52e309206cb7041425532 Mon Sep 17 00:00:00 2001 From: Taylor Jones Date: Fri, 8 May 2020 13:22:15 -0500 Subject: [PATCH] fix(tests): ensure async tests resolve, refactor unscoped eslint disables, add new eslint rules to prevent errors --- .eslintrc | 5 +- .travis.yml | 2 +- package.json | 1 + src/components/Breadcrumb/Breadcrumb.test.jsx | 6 -- src/components/Card/Card.test.jsx | 35 +++++---- src/components/Dashboard/Dashboard.test.jsx | 76 ++++++++++++------- .../DateTimePicker/DateTimePicker.jsx | 36 +++++---- .../DateTimePicker/DateTimePicker.test.jsx | 44 +++++++---- src/components/GaugeCard/GaugeCard.jsx | 7 +- src/components/GaugeCard/GaugeCard.test.jsx | 12 +-- src/components/Header/Header.test.jsx | 36 ++++----- .../List/HierarchyList/HierarchyList.test.jsx | 1 - src/components/SideNav/SideNav.test.jsx | 3 - src/components/Table/tableReducer.test.jsx | 2 +- .../TimeSeriesCard/TimeSeriesCard.test.jsx | 13 ++-- .../__snapshots__/publicAPI.test.js.snap | 2 +- src/utils/__tests__/publicAPI.test.js | 4 +- yarn.lock | 39 ++++++++++ 18 files changed, 200 insertions(+), 124 deletions(-) diff --git a/.eslintrc b/.eslintrc index a01f9753d8..c21ff0727e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -73,7 +73,10 @@ // https://nolanlawson.com/2018/03/20/smaller-lodash-bundles-with-webpack-and-babel/ "lodash/chaining": [2, "never"], "lodash/import-scope": [2, "method"], - "react/destructuring-assignment": [2, "always", { "ignoreClassFields": true }] + "react/destructuring-assignment": [2, "always", { "ignoreClassFields": true }], + "jest/expect-expect": "error", + "jest/prefer-hooks-on-top": "error" + // "jest/consistent-test-it": ["error", { "fn": "test", "withinDescribe": "it" }] }, // Testcases have less eslint rules applied to them "overrides": [ diff --git a/.travis.yml b/.travis.yml index 795f921696..8cf0ec5057 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ install: script: - yarn lint - - travis_wait yarn test --runInBand --ci --logHeapUsage --coverage && cat ./coverage/lcov.info | yarn run coveralls && rm -rf ./coverage # report coveralls status + - travis_wait yarn test --maxWorkers=2 --ci --logHeapUsage --coverage && cat ./coverage/lcov.info | yarn run coveralls && rm -rf ./coverage # report coveralls status after_success: - yarn publish-npm diff --git a/package.json b/package.json index f22440128a..e178104c21 100644 --- a/package.json +++ b/package.json @@ -218,6 +218,7 @@ "stylelint-config-recommended-scss": "^3.3.0", "stylelint-scss": "^3.10.0", "weak": "^1.0.1", + "weak-napi": "^2.0.1", "webpack": "^4.28.4", "whatwg-fetch": "^3.0.0" }, diff --git a/src/components/Breadcrumb/Breadcrumb.test.jsx b/src/components/Breadcrumb/Breadcrumb.test.jsx index c0b82fdd31..7e0a034aa6 100644 --- a/src/components/Breadcrumb/Breadcrumb.test.jsx +++ b/src/components/Breadcrumb/Breadcrumb.test.jsx @@ -22,12 +22,6 @@ describe('Breadcrumb', () => { }); describe('Breadcrumb with overflow', () => { - const originalOffsetHeight = Object.getOwnPropertyDescriptor( - HTMLElement.prototype, - 'clientWidth' - ); - const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollWidth'); - beforeAll(() => { Object.defineProperty(HTMLElement.prototype, 'clientWidth', { writable: true, diff --git a/src/components/Card/Card.test.jsx b/src/components/Card/Card.test.jsx index 4ea024e4e8..5dd26d12f4 100644 --- a/src/components/Card/Card.test.jsx +++ b/src/components/Card/Card.test.jsx @@ -1,13 +1,14 @@ import { mount } from 'enzyme'; import React from 'react'; -/* eslint-disable*/ import { Tooltip } from 'carbon-components-react'; import { render, fireEvent, waitFor } from '@testing-library/react'; import { Popup20 } from '@carbon/icons-react'; + import { CARD_SIZES, CARD_TITLE_HEIGHT, CARD_ACTIONS } from '../../constants/LayoutConstants'; +import { settings } from '../../constants/Settings'; + import CardRangePicker from './CardRangePicker'; import Card from './Card'; -import { settings } from '../../constants/Settings'; const { iotPrefix } = settings; @@ -19,17 +20,21 @@ const cardProps = { }; describe('Card testcases', () => { - test('small', () => { + it('small', () => { const wrapper = mount(); // small should have full header expect(wrapper.find(`.${iotPrefix}--card--header`)).toHaveLength(1); }); - test('child size prop', () => { + it('child size prop', () => { const childRenderInTitleCard = jest.fn(); - mount(); + mount( + + {childRenderInTitleCard} + + ); expect(childRenderInTitleCard).toHaveBeenCalledWith( { width: 0, @@ -52,7 +57,7 @@ describe('Card testcases', () => { ); }); - test('render icons', () => { + it('render icons', () => { let wrapper = mount( ); @@ -78,7 +83,7 @@ describe('Card testcases', () => { expect(wrapper.find(CardRangePicker)).toHaveLength(0); }); - test('additional prop based elements', () => { + it('additional prop based elements', () => { let wrapper = mount(); // tooltip prop will render a tooltip in the header expect(wrapper.find(`.${iotPrefix}--card--header`).find(Tooltip)).toHaveLength(1); @@ -90,16 +95,16 @@ describe('Card testcases', () => { ); expect(wrapper.find(`.${iotPrefix}--card--skeleton-wrapper`)).toHaveLength(1); }); - test('isExpanded', () => { - let wrapper = mount( + it('isExpanded', () => { + const wrapper = mount( ); - //isExpanded renders the modal wrapper around it + // isExpanded renders the modal wrapper around it expect(wrapper.find('.bx--modal')).toHaveLength(1); }); - test('card actions', () => { + it('card actions', () => { const mockOnCardAction = jest.fn(); - let wrapper = mount( + const wrapper = mount( { expect(mockOnCardAction).toHaveBeenCalledWith(cardProps.id, CARD_ACTIONS.CLOSE_EXPANDED_CARD); mockOnCardAction.mockClear(); - let wrapper2 = mount( + const wrapper2 = mount( { .props.onClick(); expect(mockOnCardAction).toHaveBeenCalledWith(cardProps.id, CARD_ACTIONS.OPEN_EXPANDED_CARD); }); - test('card editable actions', async () => { + it('card editable actions', async () => { const mockOnCardAction = jest.fn(); const { getByTitle, getByText } = render( { fireEvent.click(thirdElement); expect(mockOnCardAction).toHaveBeenCalledWith(cardProps.id, CARD_ACTIONS.DELETE_CARD); }); - test('card toolbar renders in header only when there are actions', () => { + it('card toolbar renders in header only when there are actions', () => { const wrapperWithActions = mount( ); diff --git a/src/components/Dashboard/Dashboard.test.jsx b/src/components/Dashboard/Dashboard.test.jsx index 32360a8eba..176ee76703 100644 --- a/src/components/Dashboard/Dashboard.test.jsx +++ b/src/components/Dashboard/Dashboard.test.jsx @@ -2,6 +2,7 @@ import { mount } from 'enzyme'; import React from 'react'; import Add from '@carbon/icons-react/lib/add/20'; import { iconCrash } from 'carbon-icons'; +import { render, waitFor } from '@testing-library/react'; import { CARD_SIZES, CARD_TYPES, COLORS } from '../../constants/LayoutConstants'; import { tableColumns, tableData } from '../../utils/sample'; @@ -172,35 +173,58 @@ describe('Dashboard testcases', () => { expect(wrapper.prop('onDashboardAction')).toHaveBeenCalled(); }); - test('verify onFetchData is called by each card if loading changes to true', done => { - const mockOnFetchData = jest.fn().mockImplementation(() => Promise.resolve([])); + test('verify onFetchData is called by each card if loading changes to true', () => { + return new Promise(async (done, reject) => { + try { + const mockOnFetchData = jest.fn().mockImplementation(card => Promise.resolve(card)); - const mockOnSetRefresh = jest.fn().mockImplementation(refreshDate => { - if (refreshDate) { - // Wait for the final set refresh call to exit the testcase - done(); + const mockOnSetRefresh = jest.fn().mockImplementation(refreshDate => { + if (refreshDate) { + // Wait for the final set refresh call to exit the testcase + done(); + } + }); + const mockSetIsLoading = jest.fn(); + + const { rerender } = render( + + ); + rerender( + + ); + + await waitFor(() => expect(mockOnFetchData).toHaveBeenCalledTimes(5)); + } catch (e) { + reject(e); } }); - const mockSetIsLoading = jest.fn(); - - wrapper = mount( - - ); - wrapper.setProps({ isLoading: true }); - expect(mockOnFetchData).toHaveBeenCalledTimes(5); }); test('verify onLayoutChange is called when the dashboard renders', () => { const mockOnLayoutChange = jest.fn(); diff --git a/src/components/DateTimePicker/DateTimePicker.jsx b/src/components/DateTimePicker/DateTimePicker.jsx index 2d32fdf338..f1e6be6853 100644 --- a/src/components/DateTimePicker/DateTimePicker.jsx +++ b/src/components/DateTimePicker/DateTimePicker.jsx @@ -303,22 +303,28 @@ const __unstableDateTimePicker = ({ }, }; - useEffect(() => { - window.setTimeout(() => { - if (datePickerRef && datePickerRef.current) { - datePickerRef.current.cal.open(); - // while waiting for https://github.com/carbon-design-system/carbon/issues/5713 - // the only way to display the calendar inline is to reparent its DOM to our component - const wrapper = document.getElementById(`${iotPrefix}--date-time-picker__wrapper`); - if (typeof wrapper !== 'undefined' && wrapper !== null) { - const dp = document - .getElementById(`${iotPrefix}--date-time-picker__wrapper`) - .getElementsByClassName(`${iotPrefix}--date-time-picker__datepicker`)[0]; - dp.appendChild(datePickerRef.current.cal.calendarContainer); + useEffect( + () => { + const timeout = setTimeout(() => { + if (datePickerRef && datePickerRef.current) { + datePickerRef.current.cal.open(); + // while waiting for https://github.com/carbon-design-system/carbon/issues/5713 + // the only way to display the calendar inline is to reparent its DOM to our component + const wrapper = document.getElementById(`${iotPrefix}--date-time-picker__wrapper`); + if (typeof wrapper !== 'undefined' && wrapper !== null) { + const dp = document + .getElementById(`${iotPrefix}--date-time-picker__wrapper`) + .getElementsByClassName(`${iotPrefix}--date-time-picker__datepicker`)[0]; + dp.appendChild(datePickerRef.current.cal.calendarContainer); + } } - } - }, 0); - }); + }, 0); + return () => { + clearTimeout(timeout); + }; + }, + [datePickerRef] + ); /** * Parses a value object into a human readable value diff --git a/src/components/DateTimePicker/DateTimePicker.test.jsx b/src/components/DateTimePicker/DateTimePicker.test.jsx index 3598f97176..9b774f6c2a 100644 --- a/src/components/DateTimePicker/DateTimePicker.test.jsx +++ b/src/components/DateTimePicker/DateTimePicker.test.jsx @@ -36,47 +36,52 @@ const defaultAbsoluteValue = { endTime: '10:49', }; -describe('DateTimePicker tests', () => { +describe('DateTimePicker', () => { beforeEach(() => { jest.useFakeTimers(); }); - test('it should have the first preset as value', () => { + it('should have the first preset as value', () => { const wrapper = mount(<__unstableDateTimePicker {...dateTimePickerProps} i18n={i18n} />); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); expect(wrapper.find('.bx--tooltip__trigger').text()).toEqual(PRESET_VALUES[0].label); }); - test('onApply should be called', () => { + it('should call onApply', () => { const wrapper = mount(<__unstableDateTimePicker {...dateTimePickerProps} />); wrapper .find('.iot--date-time-picker__menu-btn-apply') .first() .simulate('click'); + jest.runAllTimers(); expect(dateTimePickerProps.onApply).toHaveBeenCalled(); }); - test('onCancel should be called', () => { + it('onCancel should be called', () => { const wrapper = mount(<__unstableDateTimePicker {...dateTimePickerProps} />); wrapper .find('.iot--date-time-picker__menu-btn-cancel') .first() .simulate('click'); + jest.runAllTimers(); expect(dateTimePickerProps.onCancel).toHaveBeenCalled(); }); - test('it should render with a predefined preset', () => { + it('it should render with a predefined preset', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} defaultValue={PRESET_VALUES[1]} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); expect(wrapper.find('.bx--tooltip__trigger').text()).toEqual(PRESET_VALUES[1].label); }); - test('it should render with a predefined relative range', () => { + it('it should render with a predefined relative range', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} defaultValue={defaultRelativeValue} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); wrapper @@ -90,6 +95,7 @@ describe('DateTimePicker tests', () => { .simulate('change', { target: { value: RELATIVE_VALUES.YESTERDAY } }); const today = moment(); + jest.runAllTimers(); expect( wrapper .find('.iot--date-time-picker__field') @@ -101,7 +107,7 @@ describe('DateTimePicker tests', () => { .find('.bx--number__control-btn.up-icon') .first() .simulate('click'); - + jest.runAllTimers(); expect( wrapper .find('.iot--date-time-picker__field') @@ -113,7 +119,7 @@ describe('DateTimePicker tests', () => { .find('.iot--time-picker__controls--btn.up-icon') .first() .simulate('click'); - + jest.runAllTimers(); expect( wrapper .find('.iot--date-time-picker__field') @@ -125,13 +131,15 @@ describe('DateTimePicker tests', () => { .find('.iot--date-time-picker__menu-btn-apply') .first() .simulate('click'); + jest.runAllTimers(); expect(dateTimePickerProps.onApply).toHaveBeenCalled(); }); - test('it should render with a predefined absolute range', () => { + it('it should render with a predefined absolute range', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} defaultValue={defaultAbsoluteValue} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); expect( wrapper @@ -144,7 +152,7 @@ describe('DateTimePicker tests', () => { .find('.iot--time-picker__controls--btn.up-icon') .first() .simulate('click'); - + jest.runAllTimers(); expect( wrapper .find('.iot--date-time-picker__field') @@ -156,7 +164,7 @@ describe('DateTimePicker tests', () => { .find('.iot--time-picker__controls--btn.up-icon') .at(1) .simulate('click'); - + jest.runAllTimers(); expect( wrapper .find('.iot--date-time-picker__field') @@ -168,24 +176,26 @@ describe('DateTimePicker tests', () => { .find('.iot--date-time-picker__menu-btn-apply') .first() .simulate('click'); + jest.runAllTimers(); expect(dateTimePickerProps.onApply).toHaveBeenCalled(); }); - test('it should switch from relative to absolute', () => { + it('it should switch from relative to absolute', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} defaultValue={defaultRelativeValue} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); wrapper .find('.bx--radio-button') .at(1) .simulate('change', { target: { value: PICKER_KINDS.ABSOLUTE } }); - + jest.runAllTimers(); expect(wrapper.find('.iot--time-picker__controls--btn')).toHaveLength(4); }); - test('it should not show the relative option', () => { + it('it should not show the relative option', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} @@ -193,14 +203,16 @@ describe('DateTimePicker tests', () => { showRelativeOption={false} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); expect(wrapper.find('.bx--radio-button')).toHaveLength(0); }); - test('it should switch from relative to presets', () => { + it('it should switch from relative to presets', () => { const wrapper = mount( <__unstableDateTimePicker {...dateTimePickerProps} defaultValue={defaultRelativeValue} /> ); + jest.runAllTimers(); expect(wrapper.find('.iot--date-time-picker__field')).toHaveLength(1); wrapper .find('.iot--date-time-picker__field') @@ -211,7 +223,7 @@ describe('DateTimePicker tests', () => { .find('.iot--date-time-picker__menu-btn-back') .first() .simulate('click'); - + jest.runAllTimers(); expect(wrapper.find('.iot--time-picker__controls--btn')).toHaveLength(0); }); }); diff --git a/src/components/GaugeCard/GaugeCard.jsx b/src/components/GaugeCard/GaugeCard.jsx index 647cea6f2d..9e9476c9a3 100644 --- a/src/components/GaugeCard/GaugeCard.jsx +++ b/src/components/GaugeCard/GaugeCard.jsx @@ -62,9 +62,12 @@ const GaugeCard = ({ }) => { const [loadedState, setLoadedState] = useState(false); useEffect(() => { - setTimeout(() => { + const timeout = setTimeout(() => { setLoadedState(true); }, 1000); + return () => { + clearTimeout(timeout); + }; }, []); const myStyles = dataState @@ -190,7 +193,7 @@ GaugeCard.defaultProps = { }, ], }, - values: [], + values: {}, }; GaugeCard.displayName = 'GaugeCard'; diff --git a/src/components/GaugeCard/GaugeCard.test.jsx b/src/components/GaugeCard/GaugeCard.test.jsx index a2605aa388..1eb8be0d9f 100644 --- a/src/components/GaugeCard/GaugeCard.test.jsx +++ b/src/components/GaugeCard/GaugeCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import GaugeCard, { getColor } from './GaugeCard'; @@ -44,7 +44,6 @@ const content = { dataSourceId: 'usage', units: '%', minimumValue: 0, - maximumValue: 100, color: 'orange', backgroundColor: '#e0e0e0', shape: 'circle', @@ -99,9 +98,7 @@ const content = { ], }; -describe('GaugeCard testcases', () => { - const { container } = render(); - +describe('GaugeCard', () => { it('Threshold color should be green', () => { expect(getColor(content.gauges[2], 90).color).toEqual('green'); }); @@ -110,7 +107,10 @@ describe('GaugeCard testcases', () => { expect(getColor(content.gauges[2], 4).color).toEqual('red'); }); - it('value should be zero', () => { + it('value should be zero', async () => { + jest.useFakeTimers(); + const { container } = render(); + await waitFor(() => container.querySelector('.iot--gauge-trend')); expect(container.querySelector('.iot--gauge-trend')).toEqual(null); }); }); diff --git a/src/components/Header/Header.test.jsx b/src/components/Header/Header.test.jsx index 3478f61b43..036caf4e40 100644 --- a/src/components/Header/Header.test.jsx +++ b/src/components/Header/Header.test.jsx @@ -93,14 +93,13 @@ describe('Header testcases', () => { it('sidepanel should render', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { queryAllByLabelText } = render(
); expect(queryAllByLabelText(APP_SWITCHER).length).toBeGreaterThan(0); @@ -168,14 +167,13 @@ describe('Header testcases', () => { it('App switcher opens', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ - + // eslint-disable-next-line react/no-multi-comp content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { getByTitle } = render(
); @@ -190,17 +188,16 @@ describe('Header testcases', () => { ); }); - test('onClick expands', () => { + it('onClick expands', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ - + // eslint-disable-next-line react/no-multi-comp content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { getByTestId } = render(
); @@ -209,17 +206,16 @@ describe('Header testcases', () => { expect(menuItem.getAttribute('aria-expanded')).toBeTruthy(); }); - test('onKeyDown expands with enter', () => { + it('onKeyDown expands with enter', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ - + // eslint-disable-next-line react/no-multi-comp content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { getByTestId } = render(
); const menuTrigger = getByTestId('menuitem'); @@ -229,17 +225,16 @@ describe('Header testcases', () => { expect(menuTrigger.getAttribute('aria-expanded')).toBe('false'); }); - test('onKeyDown expands with space', () => { + it('onKeyDown expands with space', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ - + // eslint-disable-next-line react/no-multi-comp content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { getByTitle } = render(
); const menuTrigger = getByTitle('help'); @@ -249,17 +244,16 @@ describe('Header testcases', () => { expect(menuTrigger.getAttribute('aria-expanded')).toBe('false'); }); - test('onKeyDown esc on parent closes an open menu', () => { + it('onKeyDown esc on parent closes an open menu', () => { const headerPanel = { className: 'header-panel', - /* eslint-disable */ - + // eslint-disable-next-line react/no-multi-comp content: React.forwardRef((props, ref) => ( + // eslint-disable-next-line jsx-a11y/anchor-is-valid Header panel content )), - /* eslint-enable */ }; const { getByTestId, getByRole } = render(
diff --git a/src/components/List/HierarchyList/HierarchyList.test.jsx b/src/components/List/HierarchyList/HierarchyList.test.jsx index 3e4a8b5936..e54a711ff1 100644 --- a/src/components/List/HierarchyList/HierarchyList.test.jsx +++ b/src/components/List/HierarchyList/HierarchyList.test.jsx @@ -1,7 +1,6 @@ import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; - import debounce from 'lodash/debounce'; import { sampleHierarchy } from '../List.story'; diff --git a/src/components/SideNav/SideNav.test.jsx b/src/components/SideNav/SideNav.test.jsx index 991575c244..78d4c44bd4 100644 --- a/src/components/SideNav/SideNav.test.jsx +++ b/src/components/SideNav/SideNav.test.jsx @@ -9,8 +9,6 @@ import SideNav from './SideNav'; React.Fragment = ({ children }) => children; describe('SideNav testcases', () => { - // it.skip('skip this suite', () => {}); - /* eslint-disable */ const links = [ { icon: () => ( @@ -147,7 +145,6 @@ describe('SideNav testcases', () => { }, ]; - /* eslint-enable */ let mockProps; beforeEach(() => { diff --git a/src/components/Table/tableReducer.test.jsx b/src/components/Table/tableReducer.test.jsx index 1175702450..e074e81406 100644 --- a/src/components/Table/tableReducer.test.jsx +++ b/src/components/Table/tableReducer.test.jsx @@ -28,7 +28,7 @@ describe('table reducer testcases', () => { test('nothing', () => { expect(tableReducer(undefined, { type: 'BOGUS' })).toEqual({}); }); - describe('row action tests', () => { + test('row action tests', () => { const updatedRowActionState = tableReducer(initialState, tableRowActionStart('row-1')); const newRowActions = updatedRowActionState.view.table.rowActions; expect(newRowActions).toHaveLength(1); diff --git a/src/components/TimeSeriesCard/TimeSeriesCard.test.jsx b/src/components/TimeSeriesCard/TimeSeriesCard.test.jsx index ab6c194bae..9a7e3d58bb 100644 --- a/src/components/TimeSeriesCard/TimeSeriesCard.test.jsx +++ b/src/components/TimeSeriesCard/TimeSeriesCard.test.jsx @@ -5,7 +5,6 @@ import Table from '../Table/Table'; import { getIntervalChartData } from '../../utils/sample'; import { CARD_SIZES } from '../../constants/LayoutConstants'; -/* eslint-disable */ import TimeSeriesCard, { determinePrecision, valueFormatter, @@ -36,26 +35,26 @@ const timeSeriesCardProps = { }; describe('TimeSeriesCard tests', () => { - test('does not show line chart when loading', () => { + it('does not show line chart when loading', () => { let wrapper = mount(); expect(wrapper.find('LineChart')).toHaveLength(0); wrapper = mount(); expect(wrapper.find('LineChart')).toHaveLength(1); }); - test('shows table with data when expanded', () => { - let wrapper = mount(); + it('shows table with data when expanded', () => { + const wrapper = mount(); expect(wrapper.find('LineChart')).toHaveLength(1); // Carbon Table should be there expect(wrapper.find(Table)).toHaveLength(1); }); - test('determine precision', () => { + it('determine precision', () => { expect(determinePrecision(CARD_SIZES.LARGE, 700)).toEqual(0); expect(determinePrecision(CARD_SIZES.SMALL, 11.45)).toEqual(0); expect(determinePrecision(CARD_SIZES.SMALL, 1.45, 1)).toEqual(1); expect(determinePrecision(CARD_SIZES.LARGE, 1.45, 1)).toEqual(1); }); - test('valueFormatter', () => { + it('valueFormatter', () => { // Small should get 3 precision expect(valueFormatter(0.23456, CARD_SIZES.LARGE, null)).toEqual('0.235'); // default precision @@ -70,7 +69,7 @@ describe('TimeSeriesCard tests', () => { // nil expect(valueFormatter(null, CARD_SIZES.LARGE, null)).toEqual('--'); }); - test('handleTooltip should add date', () => { + it('handleTooltip should add date', () => { const defaultTooltip = '
  • existing tooltip
  • '; // the date is from 2017 const updatedTooltip = handleTooltip( diff --git a/src/utils/__tests__/__snapshots__/publicAPI.test.js.snap b/src/utils/__tests__/__snapshots__/publicAPI.test.js.snap index b61af793bc..d1e4add0a9 100644 --- a/src/utils/__tests__/__snapshots__/publicAPI.test.js.snap +++ b/src/utils/__tests__/__snapshots__/publicAPI.test.js.snap @@ -10272,7 +10272,7 @@ Map { }, "description": null, "isLoading": false, - "values": Array [], + "values": Object {}, }, "displayName": "GaugeCard", "propTypes": Object { diff --git a/src/utils/__tests__/publicAPI.test.js b/src/utils/__tests__/publicAPI.test.js index 1f433130eb..6b4ca7b263 100644 --- a/src/utils/__tests__/publicAPI.test.js +++ b/src/utils/__tests__/publicAPI.test.js @@ -50,7 +50,7 @@ beforeEach(() => { // function. This getter function should return the type of the prop type // and also specify the `isRequired` field so PropTypes.string.isRequired // works as intended - /* eslint-disable no-restricted-syntax */ + // eslint-disable-next-line no-restricted-syntax for (const type of primitive) { Object.defineProperty(PropTypes, type, { get() { @@ -75,6 +75,7 @@ beforeEach(() => { // and have it return the prop type information as a result of calling the // prop-type. We'll also need to define the `isRequired` field similar to // how we used it in the primitive prop types + // eslint-disable-next-line no-restricted-syntax for (const type of complex) { // eslint-disable-next-line func-names PropTypes[type] = function(...args) { @@ -97,7 +98,6 @@ beforeEach(() => { return value; }; } - /* eslint-enable no-restricted-syntax */ return PropTypes; }); diff --git a/yarn.lock b/yarn.lock index f55476acc4..621d350e42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9209,6 +9209,18 @@ get-stream@^5.0.0: dependencies: pump "^3.0.0" +get-symbol-from-current-process-h@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/get-symbol-from-current-process-h/-/get-symbol-from-current-process-h-1.0.2.tgz#510af52eaef873f7028854c3377f47f7bb200265" + integrity sha512-syloC6fsCt62ELLrr1VKBM1ggOpMdetX9hTrdW77UQdcApPHLmf7CI7OKcN1c9kYuNxKcDe4iJ4FY9sX3aw2xw== + +get-uv-event-loop-napi-h@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/get-uv-event-loop-napi-h/-/get-uv-event-loop-napi-h-1.0.6.tgz#42b0b06b74c3ed21fbac8e7c72845fdb7a200208" + integrity sha512-t5c9VNR84nRoF+eLiz6wFrEp1SE2Acg0wS+Ysa2zF0eROes+LzOfuTaVHxGy8AbS8rq7FHEJzjnCZo1BupwdJg== + dependencies: + get-symbol-from-current-process-h "^1.0.1" + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -13239,6 +13251,11 @@ node-abi@^2.2.0: dependencies: semver "^5.4.1" +node-addon-api@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.0.0.tgz#812446a1001a54f71663bed188314bba07e09247" + integrity sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg== + node-ask@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/node-ask/-/node-ask-1.0.1.tgz#caaa1076cc58e0364267a0903e3eadfac158396b" @@ -13278,6 +13295,11 @@ node-fetch@^2.3.0, node-fetch@^2.6.0: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== +node-gyp-build@^4.2.1: + version "4.2.2" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.2.tgz#3f44b65adaafd42fb6c3d81afd630e45c847eb66" + integrity sha512-Lqh7mrByWCM8Cf9UPqpeoVBBo5Ugx+RKu885GAzmLBVYjeywScxHXPGLa4JfYNZmcNGwzR0Glu5/9GaQZMFqyA== + node-gyp@^3.8.0: version "3.8.0" resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.8.0.tgz#540304261c330e80d0d5edce253a68cb3964218c" @@ -17356,6 +17378,14 @@ set-value@^2.0.0: is-plain-object "^2.0.3" split-string "^3.0.1" +setimmediate-napi@^1.0.3: + version "1.0.6" + resolved "https://registry.yarnpkg.com/setimmediate-napi/-/setimmediate-napi-1.0.6.tgz#43cd797ef25d66eb69c782170ea01898787b8720" + integrity sha512-sdNXN15Av1jPXuSal4Mk4tEAKn0+8lfF9Z50/negaQMrAIO9c1qM0eiCh8fT6gctp0RiCObk+6/Xfn5RMGdZoA== + dependencies: + get-symbol-from-current-process-h "^1.0.1" + get-uv-event-loop-napi-h "^1.0.5" + setimmediate@^1.0.4, setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -19521,6 +19551,15 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" +weak-napi@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/weak-napi/-/weak-napi-2.0.1.tgz#406c69e4b6924b1b336e6c93e150334bd6e6e43e" + integrity sha512-5K6swEmuZrS8jjtXon9w0Q8qWUSxQYGSp5G4NUjDerNSPSmwBsb9+DXUbr6hAbrDUGFmjeLDRqxv/ma2OfZ1Xw== + dependencies: + node-addon-api "^3.0.0" + node-gyp-build "^4.2.1" + setimmediate-napi "^1.0.3" + weak@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/weak/-/weak-1.0.1.tgz#ab99aab30706959aa0200cb8cf545bb9cb33b99e"