2021-03-17 08:22:33 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { filterBusinessExtensions } from '../flows/selective-bundle';
|
2021-06-09 03:29:45 +00:00
|
|
|
import { createInitialValues } from '../flows/selective-bundle/selective-extensions-bundle';
|
2021-03-17 08:22:33 +00:00
|
|
|
|
|
|
|
describe( 'BusinessDetails', () => {
|
|
|
|
test( 'filtering extensions', () => {
|
|
|
|
const extensions = {
|
|
|
|
'creative-mail-by-constant-contact': true,
|
|
|
|
'facebook-for-woocommerce': true,
|
|
|
|
install_extensions: true,
|
|
|
|
jetpack: true,
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads': true,
|
2021-03-17 08:22:33 +00:00
|
|
|
'mailchimp-for-woocommerce': true,
|
|
|
|
'woocommerce-payments': true,
|
|
|
|
'woocommerce-services:shipping': true,
|
|
|
|
'woocommerce-services:tax': true,
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedExtensions = [
|
|
|
|
'creative-mail-by-constant-contact',
|
|
|
|
'facebook-for-woocommerce',
|
|
|
|
'jetpack',
|
2021-05-10 09:56:47 +00:00
|
|
|
'google-listings-and-ads',
|
2021-03-17 08:22:33 +00:00
|
|
|
'mailchimp-for-woocommerce',
|
|
|
|
'woocommerce-payments',
|
|
|
|
'woocommerce-services',
|
|
|
|
];
|
|
|
|
|
|
|
|
const filteredExtensions = filterBusinessExtensions( extensions );
|
|
|
|
|
|
|
|
expect( filteredExtensions ).toEqual( expectedExtensions );
|
|
|
|
} );
|
2021-06-09 03:29:45 +00:00
|
|
|
|
|
|
|
describe( 'createInitialValues', () => {
|
|
|
|
test( 'selected by default', () => {
|
|
|
|
const extensions = [
|
|
|
|
{
|
|
|
|
plugins: [
|
|
|
|
{
|
|
|
|
key: 'visible-and-not-selected',
|
|
|
|
selected: false,
|
|
|
|
isVisible: () => true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'visible-and-selected',
|
|
|
|
selected: true,
|
|
|
|
isVisible: () => true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'this-should-not-show-at-all',
|
|
|
|
selected: true,
|
|
|
|
isVisible: () => false,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const values = createInitialValues( extensions, 'US', '', [] );
|
|
|
|
|
|
|
|
expect( values ).toEqual(
|
|
|
|
expect.objectContaining( {
|
|
|
|
'visible-and-not-selected': false,
|
|
|
|
'visible-and-selected': true,
|
|
|
|
} )
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( values ).not.toContain( 'this-should-not-show-at-all' );
|
|
|
|
} );
|
|
|
|
} );
|
2021-03-17 08:22:33 +00:00
|
|
|
} );
|