initial commit
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { emptyHiddenAddressFields } from '@woocommerce/base-utils';
|
||||
|
||||
describe( 'emptyHiddenAddressFields', () => {
|
||||
it( "Removes state from an address where the country doesn't use states", () => {
|
||||
const address = {
|
||||
first_name: 'Jonny',
|
||||
last_name: 'Awesome',
|
||||
company: 'WordPress',
|
||||
address_1: '123 Address Street',
|
||||
address_2: 'Address 2',
|
||||
city: 'Vienna',
|
||||
postcode: '1120',
|
||||
country: 'AT',
|
||||
state: 'CA', // This should be removed.
|
||||
email: 'jonny.awesome@email.com',
|
||||
phone: '',
|
||||
};
|
||||
const filteredAddress = emptyHiddenAddressFields( address );
|
||||
expect( filteredAddress ).toHaveProperty( 'state', '' );
|
||||
} );
|
||||
} );
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { formatError } from '../errors';
|
||||
|
||||
describe( 'formatError', () => {
|
||||
test( 'should format general errors', async () => {
|
||||
const error = await formatError( {
|
||||
message: 'Lorem Ipsum',
|
||||
} );
|
||||
const expectedError = {
|
||||
message: 'Lorem Ipsum',
|
||||
type: 'general',
|
||||
};
|
||||
|
||||
expect( error ).toEqual( expectedError );
|
||||
} );
|
||||
|
||||
test( 'should format API errors', async () => {
|
||||
const error = await formatError( {
|
||||
json: () => Promise.resolve( { message: 'Lorem Ipsum' } ),
|
||||
} );
|
||||
const expectedError = {
|
||||
message: 'Lorem Ipsum',
|
||||
type: 'api',
|
||||
};
|
||||
|
||||
expect( error ).toEqual( expectedError );
|
||||
} );
|
||||
|
||||
test( 'should format JSON parse errors', async () => {
|
||||
const error = await formatError( {
|
||||
json: () => Promise.reject( { message: 'Lorem Ipsum' } ),
|
||||
} );
|
||||
const expectedError = {
|
||||
message: 'Lorem Ipsum',
|
||||
type: 'general',
|
||||
};
|
||||
|
||||
expect( error ).toEqual( expectedError );
|
||||
} );
|
||||
} );
|
Reference in New Issue
Block a user