get-genesis-pro.js
1.18 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 { fireEvent, render, waitFor } from '@testing-library/react';
import user from '@testing-library/user-event';
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';
/**
* Internal dependencies
*/
import { GetGenesisPro } from '../';
jest.mock( '@wordpress/api-fetch' );
window.blockLabMigration = {};
test( 'get Genesis Pro migration step', async () => {
apiFetch.mockImplementation( () => new Promise( ( resolve ) => resolve( { success: true } ) ) );
const props = {
goToNext: jest.fn(),
goToPrevious: jest.fn(),
isStepActive: true,
isStepComplete: false,
stepIndex: 1,
};
const { getByText, getByRole } = render( <GetGenesisPro { ...props } /> );
// Because the checkbox isn't checked, the 'next' button should be disabled.
user.click( getByText( 'Next Step' ) );
expect( props.goToNext ).not.toHaveBeenCalled();
fireEvent.change(
getByRole( 'textbox' ),
{ target: { value: '1234567' } }
);
await waitFor( () =>
user.click( getByText( 'Save' ) )
);
getByText( 'Thanks! Your key is valid, and has been saved.' );
user.click( getByText( 'Next Step' ) );
expect( props.goToNext ).toHaveBeenCalled();
} );