Skip to content

Commit

Permalink
remove redundant mocks + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncdiehl11 committed Dec 6, 2023
1 parent 4676a72 commit 6060a8f
Showing 1 changed file with 1 addition and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import {
useTrackEvent,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
} from '../../../../redux/analytics'
import {
useRunCalibrationStatus,
useRunHasStarted,
useUnmatchedModulesForProtocol,
} from '../../hooks'
import { BackToTopButton } from '../BackToTopButton'

jest.mock('@opentrons/components', () => {
Expand All @@ -24,17 +19,7 @@ jest.mock('@opentrons/components', () => {
}
})
jest.mock('../../../../redux/analytics')
jest.mock('../../hooks')

const mockUseUnmatchedModulesForProtocol = useUnmatchedModulesForProtocol as jest.MockedFunction<
typeof useUnmatchedModulesForProtocol
>
const mockUseRunCalibrationStatus = useRunCalibrationStatus as jest.MockedFunction<
typeof useRunCalibrationStatus
>
const mockUseRunHasStarted = useRunHasStarted as jest.MockedFunction<
typeof useRunHasStarted
>
const mockUseTrackEvent = useTrackEvent as jest.MockedFunction<
typeof useTrackEvent
>
Expand Down Expand Up @@ -62,20 +47,6 @@ let mockTrackEvent: jest.Mock

describe('BackToTopButton', () => {
beforeEach(() => {
when(mockUseUnmatchedModulesForProtocol)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
missingModuleIds: [],
remainingAttachedModules: [],
})

when(mockUseRunCalibrationStatus)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
complete: true,
})
when(mockUseRunHasStarted).calledWith(RUN_ID).mockReturnValue(false)

mockTrackEvent = jest.fn()
when(mockUseTrackEvent).calledWith().mockReturnValue(mockTrackEvent)
})
Expand All @@ -102,46 +73,7 @@ describe('BackToTopButton', () => {
})
})

it('should not disabled with modules not connected tooltip when there are missing moduleIds', () => {
when(mockUseUnmatchedModulesForProtocol)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
missingModuleIds: ['temperatureModuleV1'],
remainingAttachedModules: [],
})
const { getByRole } = render()
const button = getByRole('button', { name: 'Back to top' })
expect(button).not.toBeDisabled()
})
it('should not be disabled with modules not connected and calibration not completed tooltip if missing cal and moduleIds', async () => {
when(mockUseUnmatchedModulesForProtocol)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
missingModuleIds: ['temperatureModuleV1'],
remainingAttachedModules: [],
})
when(mockUseRunCalibrationStatus)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
complete: false,
})
const { getByRole } = render()
const button = getByRole('button', { name: 'Back to top' })
expect(button).not.toBeDisabled()
})
it('should not be disabled with calibration not complete tooltip when calibration not complete', async () => {
when(mockUseRunCalibrationStatus)
.calledWith(ROBOT_NAME, RUN_ID)
.mockReturnValue({
complete: false,
})
const { getByRole } = render()
const button = getByRole('button', { name: 'Back to top' })
expect(button).not.toBeDisabled()
})
it('should not be disabled with protocol run started tooltip when run has started', async () => {
when(mockUseRunHasStarted).calledWith(RUN_ID).mockReturnValue(true)

it('should always be enabled', () => {
const { getByRole } = render()
const button = getByRole('button', { name: 'Back to top' })
expect(button).not.toBeDisabled()
Expand Down

0 comments on commit 6060a8f

Please sign in to comment.