1
1
import * as React from 'react'
2
+ import { fireEvent , screen } from '@testing-library/react'
3
+ import { describe , it , beforeEach , vi , expect } from 'vitest'
2
4
3
- import { renderWithProviders } from '@opentrons/components'
4
-
5
+ import { renderWithProviders } from '../../../__testing-utils__'
5
6
import { i18n } from '../../../i18n'
6
-
7
7
import { DeckFixtureSetupInstructionsModal } from '../DeckFixtureSetupInstructionsModal'
8
- import { fireEvent } from '@testing-library/react'
9
8
10
- const mockFunc = jest . fn ( )
11
- const PNG_FILE_NAME = 'deck_fixture_setup_qrcode.png'
9
+ const mockFunc = vi . fn ( )
10
+ const PNG_FILE_NAME =
11
+ '/app/src/assets/images/on-device-display/deck_fixture_setup_qrcode.png'
12
12
13
13
const render = (
14
14
props : React . ComponentProps < typeof DeckFixtureSetupInstructionsModal >
@@ -29,21 +29,21 @@ describe('Touchscreen DeckFixtureSetupInstructionsModal', () => {
29
29
} )
30
30
31
31
it ( 'should render text and image' , ( ) => {
32
- const [ { getByText , getByRole } ] = render ( props )
33
- getByText ( 'Deck fixture setup instructions' )
34
- getByText (
32
+ render ( props )
33
+ screen . getByText ( 'Deck fixture setup instructions' )
34
+ screen . getByText (
35
35
"First, unscrew and remove the deck slot where you'll install a fixture. Then put the fixture in place and attach it as needed."
36
36
)
37
- getByText (
37
+ screen . getByText (
38
38
'For details on installing different fixture types, scan the QR code or search for “deck configuration” on support.opentrons.com'
39
39
)
40
- const img = getByRole ( 'img' )
40
+ const img = screen . getByRole ( 'img' )
41
41
expect ( img . getAttribute ( 'src' ) ) . toEqual ( PNG_FILE_NAME )
42
42
} )
43
43
44
44
it ( 'should call a mock function when tapping the close icon' , ( ) => {
45
- const [ { getByLabelText } ] = render ( props )
46
- fireEvent . click ( getByLabelText ( 'closeIcon' ) )
45
+ render ( props )
46
+ fireEvent . click ( screen . getByLabelText ( 'closeIcon' ) )
47
47
expect ( mockFunc ) . toHaveBeenCalled ( )
48
48
} )
49
49
} )
@@ -58,19 +58,21 @@ describe('Desktop DeckFixtureSetupInstructionsModal', () => {
58
58
} )
59
59
60
60
it ( 'should render text, image, and button' , ( ) => {
61
- const [ { getAllByText, getByText, getByRole, queryByText } ] = render ( props )
62
- expect ( getAllByText ( 'Deck fixture setup instructions' ) . length ) . toBe ( 2 )
63
- getByText (
61
+ render ( props )
62
+ expect ( screen . getAllByText ( 'Deck fixture setup instructions' ) . length ) . toBe (
63
+ 2
64
+ )
65
+ screen . getByText (
64
66
"First, unscrew and remove the deck slot where you'll install a fixture. Then put the fixture in place and attach it as needed."
65
67
)
66
- getByText (
68
+ screen . getByText (
67
69
'For detailed instructions for different types of fixtures, scan the QR code or go to the link below.'
68
70
)
69
- const img = getByRole ( 'img' )
71
+ const img = screen . getByRole ( 'img' )
70
72
expect ( img . getAttribute ( 'src' ) ) . toEqual ( PNG_FILE_NAME )
71
73
expect (
72
- queryByText ( 'www.opentrons.com/support/fixtures' )
74
+ screen . queryByText ( 'www.opentrons.com/support/fixtures' )
73
75
) . not . toBeInTheDocument ( )
74
- getByRole ( 'button' , { name : 'Close' } )
76
+ screen . getByRole ( 'button' , { name : 'Close' } )
75
77
} )
76
78
} )
0 commit comments