update-hooks.js
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
import user from '@testing-library/user-event';
/**
* Internal dependencies
*/
import { UpdateHooks } from '../';
describe( 'update hooks migration step', () => {
it( 'displays step content when this step is active', async () => {
const props = {
goToNext: jest.fn(),
goToPrevious: jest.fn(),
isStepActive: true,
isStepComplete: false,
stepIndex: 2,
};
const { getByText } = render( <UpdateHooks { ...props } /> );
getByText( 'Update Hooks & API' );
getByText( props.stepIndex.toString() );
// It should always be possible to click the 'previous' button.
user.click( getByText( 'Previous' ) );
expect( props.goToPrevious ).toHaveBeenCalled();
} );
it( 'does not display content when this step is not active', async () => {
const props = {
goToNext: jest.fn(),
goToPrevious: jest.fn(),
isStepActive: false,
isStepComplete: false,
stepIndex: 2,
};
const { getByText } = render( <UpdateHooks { ...props } /> );
// The heading should still display.
getByText( 'Update Hooks & API' );
getByText( props.stepIndex.toString() );
// The content of the step should now display, as it's not active.
expect( screen.queryByText( 'Previous' ) ).not.toBeInTheDocument();
} );
} );