-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add UI to clear cached robots
Closes #2435
- Loading branch information
Showing
3 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 34 additions & 7 deletions
41
app/src/components/NetworkSettingsCard/__tests__/ClearDiscoveryCache.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,42 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import { shallow } from 'enzyme' | ||
|
||
import { Provider } from 'react-redux' | ||
import { mount } from 'enzyme' | ||
import noop from 'lodash/noop' | ||
import { LabeledButton } from '@opentrons/components' | ||
import { ClearDiscoveryCache } from '../ClearDiscoveryCache' | ||
import { clearDiscoveryCache } from '../../../discovery' | ||
|
||
describe('ClearDiscoveryCache', () => { | ||
it('renders clear discovery cache component', () => { | ||
const wrapper = shallow(<ClearDiscoveryCache />) | ||
expect(wrapper.find(LabeledButton).prop('label')).toBe( | ||
'Clear Discovered Robots List' | ||
) | ||
const dispatch = jest.fn() | ||
const MOCK_STORE = { | ||
dispatch, | ||
getState: noop, | ||
subscribe: noop, | ||
} | ||
|
||
const render = () => { | ||
return mount(<ClearDiscoveryCache />, { | ||
wrappingComponent: Provider, | ||
wrappingComponentProps: { store: MOCK_STORE }, | ||
}) | ||
} | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
|
||
it('renders a labelled button component', () => { | ||
const wrapper = render() | ||
const theButton = wrapper.find(LabeledButton) | ||
expect(theButton.prop('label')).toBe('Clear Discovered Robots List') | ||
expect(theButton.prop('buttonProps').children).toBe('clear') | ||
}) | ||
|
||
it('dispatches a ClearDiscoveryCache Action', () => { | ||
const wrapper = render() | ||
const buttonProps = wrapper.find(LabeledButton).prop('buttonProps') | ||
buttonProps.onClick() | ||
expect(dispatch).toHaveBeenCalledWith(clearDiscoveryCache()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters