Simplified test data setup
This commit is contained in:
parent
d10e40f8fa
commit
c40d12fc50
|
@ -1,8 +1,8 @@
|
|||
const { order, getOrderExample } = require( './order' );
|
||||
const { coupon } = require( './coupon' );
|
||||
const { refund } = require( './refund' );
|
||||
const { getExampleTaxRate } = require( './tax-rate' );
|
||||
const { getExampleVariation } = require( './variation' );
|
||||
const { getTaxRateExamples } = require( './tax-rate' );
|
||||
const { getVariationExample } = require( './variation' );
|
||||
const {
|
||||
simpleProduct,
|
||||
variableProduct,
|
||||
|
@ -19,8 +19,8 @@ module.exports = {
|
|||
coupon,
|
||||
shared,
|
||||
refund,
|
||||
getExampleTaxRate,
|
||||
getExampleVariation,
|
||||
getTaxRateExamples,
|
||||
getVariationExample,
|
||||
simpleProduct,
|
||||
variableProduct,
|
||||
variation,
|
||||
|
|
|
@ -54,23 +54,6 @@ const variableProduct = {
|
|||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Variation example
|
||||
*/
|
||||
const variation = {
|
||||
regular_price: '1.00',
|
||||
attributes: [
|
||||
{
|
||||
name: 'Size',
|
||||
option: 'Large',
|
||||
},
|
||||
{
|
||||
name: 'Colour',
|
||||
option: 'Red',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* External product example
|
||||
*/
|
||||
|
@ -92,7 +75,6 @@ module.exports = {
|
|||
simpleProduct,
|
||||
virtualProduct,
|
||||
variableProduct,
|
||||
variation,
|
||||
externalProduct,
|
||||
groupedProduct,
|
||||
};
|
||||
|
|
|
@ -6,16 +6,28 @@
|
|||
* https://woocommerce.github.io/woocommerce-rest-api-docs/#tax-rate-properties
|
||||
*
|
||||
*/
|
||||
const taxRate = {
|
||||
const standardTaxRate = {
|
||||
name: 'Standard Rate',
|
||||
rate: '10.0000',
|
||||
class: 'standard',
|
||||
};
|
||||
|
||||
const getExampleTaxRate = () => {
|
||||
return taxRate;
|
||||
const reducedTaxRate = {
|
||||
name: 'Reduced Rate',
|
||||
rate: '1.0000',
|
||||
class: 'reduced-rate',
|
||||
};
|
||||
|
||||
const zeroTaxRate = {
|
||||
name: 'Zero Rate',
|
||||
rate: '0.0000',
|
||||
class: 'zero-rate',
|
||||
};
|
||||
|
||||
const getTaxRateExamples = () => {
|
||||
return { standardTaxRate, reducedTaxRate, zeroTaxRate };
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getExampleTaxRate,
|
||||
getTaxRateExamples,
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
*/
|
||||
const variation = {
|
||||
regular_price: '20.00',
|
||||
regular_price: '1.00',
|
||||
attributes: [
|
||||
{
|
||||
name: 'Size',
|
||||
|
@ -20,10 +20,10 @@ const variation = {
|
|||
],
|
||||
};
|
||||
|
||||
const getExampleVariation = () => {
|
||||
const getVariationExample = () => {
|
||||
return variation;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getExampleVariation,
|
||||
getVariationExample,
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@ const {
|
|||
putRequest,
|
||||
deleteRequest,
|
||||
} = require( '../utils/request' );
|
||||
const { getExampleTaxRate, shared } = require( '../data' );
|
||||
const { getTaxRateExamples, shared } = require( '../data' );
|
||||
|
||||
/**
|
||||
* WooCommerce Tax Rates endpoints.
|
||||
|
@ -21,7 +21,7 @@ const taxRatesApi = {
|
|||
method: 'POST',
|
||||
path: 'taxes',
|
||||
responseCode: 201,
|
||||
payload: getExampleTaxRate(),
|
||||
payload: getTaxRateExamples(),
|
||||
taxRate: async ( taxRate ) => postRequest( 'taxes', taxRate ),
|
||||
},
|
||||
retrieve: {
|
||||
|
@ -44,7 +44,7 @@ const taxRatesApi = {
|
|||
method: 'PUT',
|
||||
path: 'taxes/<id>',
|
||||
responseCode: 200,
|
||||
payload: getExampleTaxRate(),
|
||||
payload: getTaxRateExamples(),
|
||||
taxRate: async ( taxRateId, taxRateDetails ) =>
|
||||
putRequest( `taxes/${ taxRateId }`, taxRateDetails ),
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ const taxRatesApi = {
|
|||
method: 'POST',
|
||||
path: 'taxes/batch',
|
||||
responseCode: 200,
|
||||
payload: shared.getBatchPayloadExample( getExampleTaxRate() ),
|
||||
payload: shared.getBatchPayloadExample( getTaxRateExamples() ),
|
||||
taxRates: async ( batchUpdatePayload ) =>
|
||||
postRequest( `taxes/batch`, batchUpdatePayload ),
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@ const {
|
|||
putRequest,
|
||||
deleteRequest,
|
||||
} = require( '../utils/request' );
|
||||
const { getExampleVariation, shared } = require( '../data' );
|
||||
const { getVariationExample, shared } = require( '../data' );
|
||||
|
||||
/**
|
||||
* WooCommerce Product Variation endpoints.
|
||||
|
@ -21,7 +21,7 @@ const variationsApi = {
|
|||
method: 'POST',
|
||||
path: 'products/<product_id>/variations',
|
||||
responseCode: 201,
|
||||
payload: getExampleVariation(),
|
||||
payload: getVariationExample(),
|
||||
variation: async ( productId, variation ) =>
|
||||
postRequest( `products/${ productId }/variations`, variation ),
|
||||
},
|
||||
|
@ -46,7 +46,7 @@ const variationsApi = {
|
|||
method: 'PUT',
|
||||
path: 'products/<product_id>/variations/<id>',
|
||||
responseCode: 200,
|
||||
payload: getExampleVariation(),
|
||||
payload: getVariationExample(),
|
||||
variation: async ( productId, variationId, variationDetails ) =>
|
||||
putRequest(
|
||||
`products/${ productId }/variations/${ variationId }`,
|
||||
|
@ -72,7 +72,7 @@ const variationsApi = {
|
|||
method: 'POST',
|
||||
path: 'products/<product_id>/variations/batch',
|
||||
responseCode: 200,
|
||||
payload: shared.getBatchPayloadExample( getExampleVariation() ),
|
||||
payload: shared.getBatchPayloadExample( getVariationExample() ),
|
||||
variations: async ( batchUpdatePayload ) =>
|
||||
postRequest(
|
||||
`products/${ productId }/variations/${ variationId }`,
|
||||
|
|
|
@ -6,10 +6,10 @@ const {
|
|||
} = require( '../../endpoints' );
|
||||
const {
|
||||
getOrderExample,
|
||||
getExampleTaxRate,
|
||||
getTaxRateExamples,
|
||||
getVariationExample,
|
||||
simpleProduct: defaultSimpleProduct,
|
||||
variableProduct: defaultVariableProduct,
|
||||
variation: defaultVariation,
|
||||
groupedProduct: defaultGroupedProduct,
|
||||
externalProduct: defaultExternalProduct,
|
||||
} = require( '../../data' );
|
||||
|
@ -32,7 +32,7 @@ const variableProduct = {
|
|||
};
|
||||
|
||||
const variation = {
|
||||
...defaultVariation,
|
||||
...getVariationExample(),
|
||||
regular_price: '20.00',
|
||||
tax_class: 'reduced-rate',
|
||||
};
|
||||
|
@ -54,17 +54,7 @@ const groupedProduct = defaultGroupedProduct;
|
|||
/**
|
||||
* Tax rates for each tax class
|
||||
*/
|
||||
const standardTaxRate = getExampleTaxRate();
|
||||
const reducedTaxRate = {
|
||||
name: 'Reduced Rate',
|
||||
rate: '1.0000',
|
||||
class: 'reduced-rate',
|
||||
};
|
||||
const zeroTaxRate = {
|
||||
name: 'Zero Rate',
|
||||
rate: '0.0000',
|
||||
class: 'zero-rate',
|
||||
};
|
||||
const { standardTaxRate, reducedTaxRate, zeroTaxRate } = getTaxRateExamples();
|
||||
|
||||
/**
|
||||
* Delete all pre-existing tax rates.
|
||||
|
|
Loading…
Reference in New Issue