1
1
import * as React from 'react'
2
- import { when , resetAllWhenMocks } from 'jest-when'
2
+ import { when } from 'vitest-when'
3
+ import { vi , it , expect , describe , beforeEach } from 'vitest'
3
4
import { Provider } from 'react-redux'
4
5
import { createStore , Store } from 'redux'
5
6
import { renderHook } from '@testing-library/react'
@@ -20,23 +21,14 @@ import {
20
21
} from '../../../../redux/calibration/tip-length/__fixtures__'
21
22
22
23
import { useAttachedPipetteCalibrations } from '..'
24
+ import type { State } from '../../../../redux/types'
23
25
24
- jest . mock ( '@opentrons/react-api-client' )
25
- jest . mock ( '../../../../redux/calibration' )
26
- jest . mock ( '../../../../redux/pipettes' )
27
- jest . mock ( '../../../../redux/robot-api' )
26
+ vi . mock ( '@opentrons/react-api-client' )
27
+ vi . mock ( '../../../../redux/calibration' )
28
+ vi . mock ( '../../../../redux/pipettes' )
29
+ vi . mock ( '../../../../redux/robot-api' )
28
30
29
- const mockUsePipettesQuery = usePipettesQuery as jest . MockedFunction <
30
- typeof usePipettesQuery
31
- >
32
- const mockUseAllPipetteOffsetCalibrationsQuery = useAllPipetteOffsetCalibrationsQuery as jest . MockedFunction <
33
- typeof useAllPipetteOffsetCalibrationsQuery
34
- >
35
- const mockUseAllTipLengthCalibrationsQuery = useAllTipLengthCalibrationsQuery as jest . MockedFunction <
36
- typeof useAllTipLengthCalibrationsQuery
37
- >
38
-
39
- const store : Store < any > = createStore ( jest . fn ( ) , { } )
31
+ const store : Store < State > = createStore ( state => state , { } )
40
32
41
33
const PIPETTE_CALIBRATIONS = {
42
34
left : {
@@ -61,15 +53,11 @@ describe('useAttachedPipetteCalibrations hook', () => {
61
53
</ Provider >
62
54
)
63
55
} )
64
- afterEach ( ( ) => {
65
- resetAllWhenMocks ( )
66
- jest . resetAllMocks ( )
67
- } )
68
56
69
57
it ( 'returns attached pipette calibrations when given a robot name' , ( ) => {
70
- when ( mockUsePipettesQuery )
58
+ when ( vi . mocked ( usePipettesQuery ) )
71
59
. calledWith ( { } , { } )
72
- . mockReturnValue ( {
60
+ . thenReturn ( {
73
61
data : {
74
62
left : {
75
63
id : mockPipetteOffsetCalibration1 . pipette ,
@@ -89,16 +77,16 @@ describe('useAttachedPipetteCalibrations hook', () => {
89
77
} ,
90
78
} ,
91
79
} as any )
92
- when ( mockUseAllPipetteOffsetCalibrationsQuery )
80
+ when ( vi . mocked ( useAllPipetteOffsetCalibrationsQuery ) )
93
81
. calledWith ( )
94
- . mockReturnValue ( {
82
+ . thenReturn ( {
95
83
data : {
96
84
data : [ mockPipetteOffsetCalibration1 , mockPipetteOffsetCalibration2 ] ,
97
85
} ,
98
86
} as any )
99
- when ( mockUseAllTipLengthCalibrationsQuery )
87
+ when ( vi . mocked ( useAllTipLengthCalibrationsQuery ) )
100
88
. calledWith ( )
101
- . mockReturnValue ( {
89
+ . thenReturn ( {
102
90
data : {
103
91
data : [ mockTipLengthCalibration1 , mockTipLengthCalibration2 ] ,
104
92
} ,
0 commit comments