Skip to content

Commit

Permalink
changed mock name
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Oct 24, 2024
1 parent 76f3692 commit 466d2c8
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { RECOVERY_MAP } from '/app/organisms/ErrorRecoveryFlows/constants'

describe('useHomeGripper', () => {
const mockRecoveryCommands = {
homeGripper: vi.fn().mockResolvedValue(undefined),
updatePositionEstimatorsAndHomeGripper: vi
.fn()
.mockResolvedValue(undefined),
}

const mockRouteUpdateActions = {
Expand Down Expand Up @@ -43,7 +45,9 @@ describe('useHomeGripper', () => {
expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith(
true
)
expect(mockRecoveryCommands.homeGripper).toHaveBeenCalled()
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).toHaveBeenCalled()
expect(mockRouteUpdateActions.handleMotionRouting).toHaveBeenCalledWith(
false
)
Expand All @@ -60,7 +64,9 @@ describe('useHomeGripper', () => {
})

expect(mockRouteUpdateActions.goBackPrevStep).toHaveBeenCalled()
expect(mockRecoveryCommands.homeGripper).not.toHaveBeenCalled()
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).not.toHaveBeenCalled()
})

it('should not home again if already homed once', async () => {
Expand All @@ -77,11 +83,15 @@ describe('useHomeGripper', () => {
await new Promise(resolve => setTimeout(resolve, 0))
})

expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1)
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).toHaveBeenCalledTimes(1)

rerender()

expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1)
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).toHaveBeenCalledTimes(1)
})

it('should reset hasHomedOnce when step changes to non-manual gripper step and back', async () => {
Expand All @@ -103,7 +113,9 @@ describe('useHomeGripper', () => {
await new Promise(resolve => setTimeout(resolve, 0))
})

expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(1)
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).toHaveBeenCalledTimes(1)

rerender({ recoveryMap: { step: 'SOME_OTHER_STEP' } as any })

Expand All @@ -117,6 +129,8 @@ describe('useHomeGripper', () => {
await new Promise(resolve => setTimeout(resolve, 0))
})

expect(mockRecoveryCommands.homeGripper).toHaveBeenCalledTimes(2)
expect(
mockRecoveryCommands.updatePositionEstimatorsAndHomeGripper
).toHaveBeenCalledTimes(2)
})
})

0 comments on commit 466d2c8

Please sign in to comment.