* Update payment-method-data-context tests to use userEvent

* Update mini cart block tests to use userEvent

* Update payment methods tests to use userEvent
This commit is contained in:
Thomas Roberts 2022-01-31 10:53:21 +00:00 committed by GitHub
parent afd9d42805
commit c7aa3a75b9
3 changed files with 12 additions and 17 deletions

View File

@ -1,13 +1,8 @@
/**
* External dependencies
*/
import {
render,
screen,
fireEvent,
waitFor,
act,
} from '@testing-library/react';
import { render, screen, waitFor, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { previewCart } from '@woocommerce/resource-previews';
import { dispatch } from '@wordpress/data';
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
@ -186,7 +181,7 @@ describe( 'Testing Payment Method Data Context Provider', () => {
act( () => {
// Express payment method clicked.
fireEvent.click(
userEvent.click(
screen.getByText( 'express-payment express payment method' )
);
} );
@ -200,7 +195,7 @@ describe( 'Testing Payment Method Data Context Provider', () => {
act( () => {
// Express payment method closed.
fireEvent.click(
userEvent.click(
screen.getByText(
'express-payment express payment method close'
)
@ -285,7 +280,7 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
act( () => {
// Express payment method clicked.
fireEvent.click(
userEvent.click(
screen.getByText( 'express-payment express payment method' )
);
} );
@ -301,7 +296,7 @@ describe( 'Testing Payment Method Data Context Provider with saved cards turned
act( () => {
// Express payment method closed.
fireEvent.click(
userEvent.click(
screen.getByText(
'express-payment express payment method close'
)

View File

@ -5,7 +5,6 @@ import {
act,
render,
screen,
fireEvent,
waitFor,
waitForElementToBeRemoved,
} from '@testing-library/react';
@ -14,6 +13,7 @@ import { dispatch } from '@wordpress/data';
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
import { SlotFillProvider } from '@woocommerce/blocks-checkout';
import { default as fetchMock } from 'jest-fetch-mock';
import userEvent from '@testing-library/user-event';
/**
* Internal dependencies
@ -68,7 +68,7 @@ describe( 'Testing Mini Cart', () => {
render( <MiniCartBlock /> );
await waitFor( () => expect( fetchMock ).toHaveBeenCalled() );
act( () => {
fireEvent.click( screen.getByLabelText( /items/i ) );
userEvent.click( screen.getByLabelText( /items/i ) );
} );
expect( fetchMock ).toHaveBeenCalledTimes( 1 );
@ -82,7 +82,7 @@ describe( 'Testing Mini Cart', () => {
await waitFor( () => expect( fetchMock ).toHaveBeenCalled() );
act( () => {
fireEvent.click( screen.getByLabelText( /items/i ) );
userEvent.click( screen.getByLabelText( /items/i ) );
} );
expect( fetchMock ).toHaveBeenCalledTimes( 1 );

View File

@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import { previewCart } from '@woocommerce/resource-previews';
import { dispatch } from '@wordpress/data';
import { CART_STORE_KEY as storeKey } from '@woocommerce/block-data';
@ -14,7 +14,7 @@ import {
PaymentMethodDataProvider,
usePaymentMethodDataContext,
} from '@woocommerce/base-context';
import userEvent from '@testing-library/user-event';
/**
* Internal dependencies
*/
@ -142,7 +142,7 @@ describe( 'PaymentMethods', () => {
expect( savedToken ).toBeNull();
} );
fireEvent.click( screen.getByText( 'Select new payment' ) );
userEvent.click( screen.getByText( 'Select new payment' ) );
await waitFor( () => {
const activePaymentMethod = screen.queryByText(