Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Aug 5, 2021
1 parent e6d1654 commit 30411ee
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions assets/js/base/components/cart-checkout/address-form/test/index.js
Expand Up @@ -53,18 +53,15 @@ const inputAddress = ( {
postcode = null,
} ) => {
if ( country ) {
const countryButton = screen.getByRole( 'button', {
name: countryRegExp,
} );
userEvent.click( countryButton );
userEvent.click( screen.getByRole( 'option', { name: country } ) );
const countryInput = screen.getByLabelText( countryRegExp );
userEvent.type( countryInput, country );
}
if ( city ) {
const cityInput = screen.getByLabelText( cityRegExp );
userEvent.type( cityInput, city );
}
if ( state ) {
const stateButton = screen.queryByRole( 'button', {
const stateButton = screen.queryByRole( 'combobox', {
name: stateRegExp,
} );
// State input might be a select or a text input.
Expand Down Expand Up @@ -162,17 +159,11 @@ describe( 'AddressForm Component', () => {
inputAddress( secondaryAddress );
// Only update `country` to verify other values are reset.
inputAddress( { country: primaryAddress.country } );

expect( screen.getByLabelText( cityRegExp ).value ).toBe( '' );
expect( screen.getByLabelText( stateRegExp ).value ).toBe( '' );
expect( screen.getByLabelText( postalCodeRegExp ).value ).toBe( '' );

// Repeat the test with an address which has a select for the state.
inputAddress( tertiaryAddress );
inputAddress( { country: primaryAddress.country } );

expect( screen.getByLabelText( cityRegExp ).value ).toBe( '' );
expect( screen.getByLabelText( stateRegExp ).value ).toBe( '' );
expect( screen.getByLabelText( postalCodeRegExp ).value ).toBe( '' );
} );
} );

0 comments on commit 30411ee

Please sign in to comment.