2018-07-13 13:33:15 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { setLocaleData } from '@wordpress/i18n';
|
2020-04-16 23:58:36 +00:00
|
|
|
import { registerStore } from '@wordpress/data';
|
2021-06-18 05:13:17 +00:00
|
|
|
import 'regenerator-runtime/runtime';
|
2018-07-13 13:33:15 +00:00
|
|
|
|
2018-05-16 14:59:03 +00:00
|
|
|
// Set up `wp.*` aliases. Doing this because any tests importing wp stuff will
|
|
|
|
// likely run into this.
|
|
|
|
global.wp = {
|
|
|
|
shortcode: {
|
|
|
|
next() {},
|
|
|
|
regexp: jest.fn().mockReturnValue( new RegExp() ),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-08-20 21:18:13 +00:00
|
|
|
global.wc = {};
|
|
|
|
|
2020-04-16 23:58:36 +00:00
|
|
|
const wordPressPackages = [ 'element', 'date', 'data' ];
|
2018-10-30 18:57:48 +00:00
|
|
|
|
|
|
|
const wooCommercePackages = [
|
|
|
|
'components',
|
2018-11-06 21:53:22 +00:00
|
|
|
'csv',
|
2018-10-30 18:57:48 +00:00
|
|
|
'currency',
|
|
|
|
'date',
|
2018-11-05 21:02:04 +00:00
|
|
|
'navigation',
|
2019-01-29 16:48:46 +00:00
|
|
|
'number',
|
2020-04-16 23:58:36 +00:00
|
|
|
'data',
|
2018-10-30 18:57:48 +00:00
|
|
|
];
|
|
|
|
|
2021-04-15 01:32:46 +00:00
|
|
|
global.wcTracks = {
|
|
|
|
isEnabled: false,
|
|
|
|
};
|
|
|
|
|
2019-09-23 21:47:08 +00:00
|
|
|
// aliases
|
2018-06-20 17:43:53 +00:00
|
|
|
global.wcSettings = {
|
|
|
|
adminUrl: 'https://vagrant.local/wp/wp-admin/',
|
2019-09-23 21:47:08 +00:00
|
|
|
countries: [],
|
|
|
|
currency: {
|
|
|
|
code: 'USD',
|
|
|
|
precision: 2,
|
|
|
|
symbol: '$',
|
|
|
|
symbolPosition: 'left',
|
|
|
|
decimalSeparator: '.',
|
|
|
|
priceFormat: '%1$s%2$s',
|
|
|
|
thousandSeparator: ',',
|
|
|
|
},
|
|
|
|
defaultDateRange: 'period=month&compare=previous_year',
|
2018-07-04 01:50:12 +00:00
|
|
|
date: {
|
|
|
|
dow: 0,
|
|
|
|
},
|
2019-09-23 21:47:08 +00:00
|
|
|
locale: {
|
|
|
|
siteLocale: 'en_US',
|
|
|
|
userLocale: 'en_US',
|
|
|
|
weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
|
|
|
|
},
|
2018-10-18 09:34:37 +00:00
|
|
|
orderStatuses: {
|
2018-11-28 02:58:17 +00:00
|
|
|
pending: 'Pending payment',
|
|
|
|
processing: 'Processing',
|
|
|
|
'on-hold': 'On hold',
|
|
|
|
completed: 'Completed',
|
|
|
|
cancelled: 'Cancelled',
|
|
|
|
refunded: 'Refunded',
|
|
|
|
failed: 'Failed',
|
2018-10-18 09:34:37 +00:00
|
|
|
},
|
2019-05-22 21:43:04 +00:00
|
|
|
wcAdminSettings: {
|
|
|
|
woocommerce_actionable_order_statuses: [],
|
|
|
|
woocommerce_excluded_report_order_statuses: [],
|
|
|
|
},
|
2020-05-04 22:58:39 +00:00
|
|
|
dataEndpoints: {
|
2021-04-15 01:32:46 +00:00
|
|
|
countries: [],
|
2020-05-04 22:58:39 +00:00
|
|
|
performanceIndicators: [
|
|
|
|
{
|
|
|
|
chart: 'total_sales',
|
|
|
|
label: 'Total Sales',
|
|
|
|
stat: 'revenue/total_sales',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
chart: 'net_revenue',
|
|
|
|
label: 'Net Sales',
|
|
|
|
stat: 'revenue/net_revenue',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
chart: 'orders_count',
|
|
|
|
label: 'Orders',
|
|
|
|
stat: 'orders/orders_count',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
chart: 'items_sold',
|
|
|
|
label: 'Items Sold',
|
|
|
|
stat: 'products/items_sold',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-06-20 17:43:53 +00:00
|
|
|
};
|
2018-05-28 10:55:19 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
wordPressPackages.forEach( ( lib ) => {
|
2019-09-23 21:47:08 +00:00
|
|
|
Object.defineProperty( global.wp, lib, {
|
|
|
|
get: () => require( `@wordpress/${ lib }` ),
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
wooCommercePackages.forEach( ( lib ) => {
|
2019-09-23 21:47:08 +00:00
|
|
|
Object.defineProperty( global.wc, lib, {
|
|
|
|
get: () => require( `@woocommerce/${ lib }` ),
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
2019-02-12 20:02:02 +00:00
|
|
|
const config = require( '../../config/development.json' );
|
2020-08-12 23:29:48 +00:00
|
|
|
|
|
|
|
// Check if test is jsdom or node
|
|
|
|
if ( global.window ) {
|
|
|
|
window.wcAdminFeatures = config && config.features ? config.features : {};
|
|
|
|
}
|
2019-02-12 20:02:02 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
setLocaleData(
|
|
|
|
{ '': { domain: 'woocommerce-admin', lang: 'en_US' } },
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2020-04-16 23:58:36 +00:00
|
|
|
|
|
|
|
// Mock core/notices store for components dispatching core notices
|
|
|
|
registerStore( 'core/notices', {
|
|
|
|
reducer: () => {
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
createNotice: () => {},
|
|
|
|
},
|
|
|
|
selectors: {},
|
|
|
|
} );
|