-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(app): fix LPC button #8502
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(app): fix LPC button
closes #8494
- Loading branch information
commit 59fe987e8e71de4be595710004bd39cbf7b14617
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
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
85 changes: 85 additions & 0 deletions
85
app/src/organisms/ProtocolSetup/LabwarePositionCheck/__tests__/LabwarePositionCheck.test.tsx
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import * as React from 'react' | ||
import { resetAllWhenMocks, when } from 'jest-when' | ||
import { renderWithProviders } from '@opentrons/components/src/testing/utils' | ||
import { fireEvent } from '@testing-library/dom' | ||
import { i18n } from '../../../../i18n' | ||
import { LabwarePositionCheck } from '../index' | ||
import { GenericStepScreen } from '../GenericStepScreen' | ||
import { IntroScreen } from '../IntroScreen' | ||
import { useSteps } from '../hooks' | ||
import { LabwarePositionCheckStep } from '../types' | ||
|
||
jest.mock('../GenericStepScreen') | ||
jest.mock('../IntroScreen') | ||
jest.mock('../hooks') | ||
|
||
const mockGenericStepScreen = GenericStepScreen as jest.MockedFunction< | ||
typeof GenericStepScreen | ||
> | ||
const mockIntroScreen = IntroScreen as jest.MockedFunction<typeof IntroScreen> | ||
const mockUseSteps = useSteps as jest.MockedFunction<typeof useSteps> | ||
|
||
const PICKUP_TIP_LABWARE_ID = 'PICKUP_TIP_LABWARE_ID' | ||
const PRIMARY_PIPETTE_ID = 'PRIMARY_PIPETTE_ID' | ||
|
||
const render = (props: React.ComponentProps<typeof LabwarePositionCheck>) => { | ||
return renderWithProviders(<LabwarePositionCheck {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
describe('LabwarePositionCheck', () => { | ||
let props: React.ComponentProps<typeof LabwarePositionCheck> | ||
beforeEach(() => { | ||
props = { | ||
onCloseClick: jest.fn(), | ||
} | ||
when(mockUseSteps) | ||
.calledWith() | ||
.mockReturnValue([ | ||
{ | ||
commands: [ | ||
{ | ||
command: 'pickUpTip', | ||
params: { | ||
pipette: PRIMARY_PIPETTE_ID, | ||
labware: PICKUP_TIP_LABWARE_ID, | ||
}, | ||
}, | ||
], | ||
labwareId: | ||
'1d57fc10-67ad-11ea-9f8b-3b50068bd62d:opentrons/opentrons_96_filtertiprack_200ul/1', | ||
section: 'PRIMARY_PIPETTE_TIPRACKS', | ||
} as LabwarePositionCheckStep, | ||
]) | ||
mockIntroScreen.mockReturnValue(<div>Mock Intro Screen Component </div>) | ||
mockGenericStepScreen.mockReturnValue(null) | ||
}) | ||
afterEach(() => { | ||
resetAllWhenMocks() | ||
jest.resetAllMocks() | ||
}) | ||
it('renders LabwarePositionCheck header and button and no components', () => { | ||
const { getByRole } = render(props) | ||
getByRole('heading', { | ||
name: 'Labware Position Check', | ||
}) | ||
getByRole('button', { | ||
name: 'exit', | ||
}) | ||
}) | ||
it('renders LabwarePositionCheck header and exit button is pressed', () => { | ||
const { getByRole } = render(props) | ||
expect(props.onCloseClick).not.toHaveBeenCalled() | ||
const exitButton = getByRole('button', { | ||
name: 'exit', | ||
}) | ||
fireEvent.click(exitButton) | ||
expect(props.onCloseClick).toHaveBeenCalled() | ||
}) | ||
|
||
it('renders LabwarePositionCheck with IntroScreen component', () => { | ||
const { getByText } = render(props) | ||
getByText('Mock Intro Screen Component') | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hell yeah, thanks for this @jerader!!