diff --git a/packages/js/api-core-tests/data/index.js b/packages/js/api-core-tests/data/index.js index 81d0c8e976e..26db6e362ef 100644 --- a/packages/js/api-core-tests/data/index.js +++ b/packages/js/api-core-tests/data/index.js @@ -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, diff --git a/packages/js/api-core-tests/data/products-crud.js b/packages/js/api-core-tests/data/products-crud.js index 68a0fbd09ef..18cb8e076cf 100644 --- a/packages/js/api-core-tests/data/products-crud.js +++ b/packages/js/api-core-tests/data/products-crud.js @@ -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, }; diff --git a/packages/js/api-core-tests/data/tax-rate.js b/packages/js/api-core-tests/data/tax-rate.js index 98449e58eea..670f6ca76b4 100644 --- a/packages/js/api-core-tests/data/tax-rate.js +++ b/packages/js/api-core-tests/data/tax-rate.js @@ -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, }; diff --git a/packages/js/api-core-tests/data/variation.js b/packages/js/api-core-tests/data/variation.js index 46fab09a5cf..465a71248b0 100644 --- a/packages/js/api-core-tests/data/variation.js +++ b/packages/js/api-core-tests/data/variation.js @@ -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, }; diff --git a/packages/js/api-core-tests/endpoints/tax-rates.js b/packages/js/api-core-tests/endpoints/tax-rates.js index ae2afa2a4e9..cfe86f8e7ea 100644 --- a/packages/js/api-core-tests/endpoints/tax-rates.js +++ b/packages/js/api-core-tests/endpoints/tax-rates.js @@ -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/', 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 ), }, diff --git a/packages/js/api-core-tests/endpoints/variations.js b/packages/js/api-core-tests/endpoints/variations.js index 68584fa52fd..816910a4872 100644 --- a/packages/js/api-core-tests/endpoints/variations.js +++ b/packages/js/api-core-tests/endpoints/variations.js @@ -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//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//variations/', 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//variations/batch', responseCode: 200, - payload: shared.getBatchPayloadExample( getExampleVariation() ), + payload: shared.getBatchPayloadExample( getVariationExample() ), variations: async ( batchUpdatePayload ) => postRequest( `products/${ productId }/variations/${ variationId }`, diff --git a/packages/js/api-core-tests/tests/orders/order-complex.test.js b/packages/js/api-core-tests/tests/orders/order-complex.test.js index 83381d0bdd5..ccc6d50678b 100644 --- a/packages/js/api-core-tests/tests/orders/order-complex.test.js +++ b/packages/js/api-core-tests/tests/orders/order-complex.test.js @@ -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.