1
1
import * as React from 'react'
2
- import { renderWithProviders } from '@opentrons/components'
2
+ import { describe , it , vi , beforeEach , expect } from 'vitest'
3
+ import '@testing-library/jest-dom/vitest'
4
+ import { renderWithProviders } from '../../../../__testing-utils__'
3
5
import { useInstrumentsQuery } from '@opentrons/react-api-client'
4
- import { fireEvent } from '@testing-library/react'
6
+ import { fireEvent , screen } from '@testing-library/react'
5
7
import { i18n } from '../../../../i18n'
6
8
import { AboutPipetteSlideout } from '../AboutPipetteSlideout'
7
9
import { mockLeftSpecs } from '../../../../redux/pipettes/__fixtures__'
8
10
import { LEFT } from '../../../../redux/pipettes'
9
11
10
- jest . mock ( '@opentrons/react-api-client' )
11
-
12
- const mockUseInstrumentsQuery = useInstrumentsQuery as jest . MockedFunction <
13
- typeof useInstrumentsQuery
14
- >
12
+ vi . mock ( '@opentrons/react-api-client' )
15
13
16
14
const render = ( props : React . ComponentProps < typeof AboutPipetteSlideout > ) => {
17
15
return renderWithProviders ( < AboutPipetteSlideout { ...props } /> , {
@@ -27,28 +25,25 @@ describe('AboutPipetteSlideout', () => {
27
25
pipetteName : mockLeftSpecs . displayName ,
28
26
mount : LEFT ,
29
27
isExpanded : true ,
30
- onCloseClick : jest . fn ( ) ,
28
+ onCloseClick : vi . fn ( ) ,
31
29
}
32
- mockUseInstrumentsQuery . mockReturnValue ( {
30
+ vi . mocked ( useInstrumentsQuery ) . mockReturnValue ( {
33
31
data : { data : [ ] } ,
34
32
} as any )
35
33
} )
36
- afterEach ( ( ) => {
37
- jest . resetAllMocks ( )
38
- } )
39
34
40
35
it ( 'renders correct info' , ( ) => {
41
- const { getByText , getByRole } = render ( props )
36
+ render ( props )
42
37
43
- getByText ( 'About Left Pipette Pipette' )
44
- getByText ( '123' )
45
- getByText ( 'SERIAL NUMBER' )
46
- const button = getByRole ( 'button' , { name : / e x i t / i } )
38
+ screen . getByText ( 'About Left Pipette Pipette' )
39
+ screen . getByText ( '123' )
40
+ screen . getByText ( 'SERIAL NUMBER' )
41
+ const button = screen . getByRole ( 'button' , { name : / e x i t / i } )
47
42
fireEvent . click ( button )
48
43
expect ( props . onCloseClick ) . toHaveBeenCalled ( )
49
44
} )
50
45
it ( 'renders the firmware version if it exists' , ( ) => {
51
- mockUseInstrumentsQuery . mockReturnValue ( {
46
+ vi . mocked ( useInstrumentsQuery ) . mockReturnValue ( {
52
47
data : {
53
48
data : [
54
49
{
@@ -61,9 +56,9 @@ describe('AboutPipetteSlideout', () => {
61
56
} ,
62
57
} as any )
63
58
64
- const { getByText } = render ( props )
59
+ render ( props )
65
60
66
- getByText ( 'CURRENT VERSION' )
67
- getByText ( '12' )
61
+ screen . getByText ( 'CURRENT VERSION' )
62
+ screen . getByText ( '12' )
68
63
} )
69
64
} )
0 commit comments