Added update and retrieve shipping zone tests
This commit is contained in:
parent
32d0a43a74
commit
8c54bcb748
|
@ -4,6 +4,7 @@
|
|||
const {
|
||||
getRequest,
|
||||
postRequest,
|
||||
putRequest,
|
||||
deleteRequest,
|
||||
} = require( '../utils/request' );
|
||||
|
||||
|
@ -37,6 +38,17 @@ const shippingZonesApi = {
|
|||
responseCode: 200,
|
||||
shippingZone: async () => getRequest( `shipping/zones` ),
|
||||
},
|
||||
update: {
|
||||
name: 'Update a shipping zone',
|
||||
method: 'PUT',
|
||||
path: 'shipping/zones/<id>',
|
||||
responseCode: 200,
|
||||
shippingZone: async ( shippingZoneId, updatedShippingZone ) =>
|
||||
putRequest(
|
||||
`shipping/zones/${ shippingZoneId }`,
|
||||
updatedShippingZone
|
||||
),
|
||||
},
|
||||
delete: {
|
||||
name: 'Delete a shipping zone',
|
||||
method: 'DELETE',
|
||||
|
|
|
@ -2,7 +2,7 @@ const { shippingZonesApi } = require( '../../endpoints' );
|
|||
const { getShippingZoneExample } = require( '../../data' );
|
||||
|
||||
/**
|
||||
* Shipping zone to be created.
|
||||
* Shipping zone to be created, retrieved, updated, and deleted by the tests.
|
||||
*/
|
||||
const shippingZone = getShippingZoneExample();
|
||||
|
||||
|
@ -23,10 +23,34 @@ describe( 'Shipping zones API tests', () => {
|
|||
expect( typeof body.id ).toEqual( 'number' );
|
||||
expect( body.name ).toEqual( shippingZone.name );
|
||||
|
||||
// Save the shipping zone ID
|
||||
// Save the shipping zone ID. It will be used by other tests.
|
||||
shippingZone.id = body.id;
|
||||
} );
|
||||
|
||||
it( 'can retrieve a shipping zone', async () => {
|
||||
const { status, body } = await shippingZonesApi.retrieve.shippingZone(
|
||||
shippingZone.id
|
||||
);
|
||||
|
||||
expect( status ).toEqual( shippingZonesApi.retrieve.responseCode );
|
||||
expect( body.id ).toEqual( shippingZone.id );
|
||||
} );
|
||||
|
||||
it( 'can update a shipping zone', async () => {
|
||||
const updatedShippingZone = {
|
||||
name: 'United States (Domestic)',
|
||||
};
|
||||
|
||||
const { status, body } = await shippingZonesApi.update.shippingZone(
|
||||
shippingZone.id,
|
||||
updatedShippingZone
|
||||
);
|
||||
|
||||
expect( status ).toEqual( shippingZonesApi.retrieve.responseCode );
|
||||
expect( body.id ).toEqual( shippingZone.id );
|
||||
expect( body.name ).toEqual( updatedShippingZone.name );
|
||||
} );
|
||||
|
||||
it( 'can delete a shipping zone', async () => {
|
||||
const { status, body } = await shippingZonesApi.delete.shippingZone(
|
||||
shippingZone.id,
|
||||
|
|
Loading…
Reference in New Issue