@riosst100/pwa-marketplace 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Utilities/graphQL.js +76 -76
- package/src/componentOverrideMapping.js +17 -17
- package/src/components/BecomeSeller/becomeSeller.js +335 -335
- package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
- package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
- package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
- package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
- package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
- package/src/components/Filter/index.js +53 -53
- package/src/components/Header/becomeSellerLink.js +28 -28
- package/src/components/Header/becomeSellerLink.module.css +12 -12
- package/src/components/Header/websiteSwitcher.js +109 -109
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +35 -0
- package/src/components/Pagination/index.js +49 -49
- package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
- package/src/components/ProductItem/index.js +50 -50
- package/src/components/Search/index.js +16 -16
- package/src/components/Seller/index.js +1 -1
- package/src/components/Seller/seller.js +57 -249
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
- package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
- package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +161 -0
- package/src/components/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +86 -90
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -19
- package/src/components/SellerLocation/sellerLocationItem.js +27 -27
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +46 -46
- package/src/components/SellerReview/index.js +1 -1
- package/src/components/SellerReview/sellerReview.js +143 -143
- package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
- package/src/components/SellerVerification/sellerVerification.js +198 -198
- package/src/components/SellerVerification/sellerVerification.module.css +47 -47
- package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
- package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
- package/src/components/SortBy/index.js +24 -24
- package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
- package/src/components/commons/Slider/index.js +13 -13
- package/src/components/commons/Tabs/index.js +64 -64
- package/src/index.js +6 -6
- package/src/intercept.js +113 -113
- package/src/moduleOverrideWebpackPlugin.js +70 -70
- package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
- package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
- package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
- package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
- package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
- package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
- package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
- package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
- package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
- package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
- package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
- package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
- package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
- package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
- package/src/queries/index.js +30 -30
- package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
- package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
- package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
- package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
- package/src/talons/Header/useBecomeSellerLink.js +13 -13
- package/src/talons/Header/useWebsiteSwitcher.js +218 -218
- package/src/talons/Seller/seller.gql.js +204 -139
- package/src/talons/Seller/useSeller.js +71 -66
- package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
- package/src/talons/SellerCountry/useSellerCountry.js +25 -25
- package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
- package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
- package/src/theme/vars.js +6 -6
- package/src/util/mapSeller.js +7 -7
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Form } from 'informed';
|
|
3
|
-
import { act } from 'react-test-renderer';
|
|
4
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
5
|
-
import Trigger from '../../Trigger';
|
|
6
|
-
import SearchField from '../searchField';
|
|
7
|
-
|
|
8
|
-
jest.mock('@magento/peregrine/lib/context/app', () => {
|
|
9
|
-
const state = {};
|
|
10
|
-
const api = {};
|
|
11
|
-
return {
|
|
12
|
-
useAppContext: jest.fn(() => [state, api])
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
jest.mock('../../../classify');
|
|
17
|
-
jest.mock('../../Trigger', () => () => null);
|
|
18
|
-
|
|
19
|
-
const onChange = jest.fn();
|
|
20
|
-
const onFocus = jest.fn();
|
|
21
|
-
|
|
22
|
-
test('renders correctly', () => {
|
|
23
|
-
const instance = createTestInstance(
|
|
24
|
-
<Form initialValues={{ search_query: '' }}>
|
|
25
|
-
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
26
|
-
</Form>
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('renders no reset button if value is empty', () => {
|
|
33
|
-
const { root } = createTestInstance(
|
|
34
|
-
<Form initialValues={{ search_query: '' }}>
|
|
35
|
-
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
36
|
-
</Form>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
expect(root.findAllByType(Trigger)).toHaveLength(0);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('renders a reset button', () => {
|
|
43
|
-
let formApi;
|
|
44
|
-
|
|
45
|
-
const { root } = createTestInstance(
|
|
46
|
-
<Form
|
|
47
|
-
getApi={api => {
|
|
48
|
-
formApi = api;
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
52
|
-
</Form>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
act(() => {
|
|
56
|
-
formApi.setValue('search_query', 'a');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
expect(root.findAllByType(Trigger)).toHaveLength(1);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('reset button resets the form', () => {
|
|
63
|
-
let formApi;
|
|
64
|
-
|
|
65
|
-
const { root } = createTestInstance(
|
|
66
|
-
<Form
|
|
67
|
-
getApi={api => {
|
|
68
|
-
formApi = api;
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
72
|
-
</Form>
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
act(() => {
|
|
76
|
-
formApi.setValue('search_query', 'a');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const trigger = root.findByType(Trigger);
|
|
80
|
-
const { action: resetForm } = trigger.props;
|
|
81
|
-
|
|
82
|
-
act(() => {
|
|
83
|
-
resetForm();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(formApi.getValue('search_query')).toBeUndefined();
|
|
87
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form } from 'informed';
|
|
3
|
+
import { act } from 'react-test-renderer';
|
|
4
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
5
|
+
import Trigger from '../../Trigger';
|
|
6
|
+
import SearchField from '../searchField';
|
|
7
|
+
|
|
8
|
+
jest.mock('@magento/peregrine/lib/context/app', () => {
|
|
9
|
+
const state = {};
|
|
10
|
+
const api = {};
|
|
11
|
+
return {
|
|
12
|
+
useAppContext: jest.fn(() => [state, api])
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
jest.mock('../../../classify');
|
|
17
|
+
jest.mock('../../Trigger', () => () => null);
|
|
18
|
+
|
|
19
|
+
const onChange = jest.fn();
|
|
20
|
+
const onFocus = jest.fn();
|
|
21
|
+
|
|
22
|
+
test('renders correctly', () => {
|
|
23
|
+
const instance = createTestInstance(
|
|
24
|
+
<Form initialValues={{ search_query: '' }}>
|
|
25
|
+
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
26
|
+
</Form>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('renders no reset button if value is empty', () => {
|
|
33
|
+
const { root } = createTestInstance(
|
|
34
|
+
<Form initialValues={{ search_query: '' }}>
|
|
35
|
+
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
36
|
+
</Form>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(root.findAllByType(Trigger)).toHaveLength(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('renders a reset button', () => {
|
|
43
|
+
let formApi;
|
|
44
|
+
|
|
45
|
+
const { root } = createTestInstance(
|
|
46
|
+
<Form
|
|
47
|
+
getApi={api => {
|
|
48
|
+
formApi = api;
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
52
|
+
</Form>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
act(() => {
|
|
56
|
+
formApi.setValue('search_query', 'a');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(root.findAllByType(Trigger)).toHaveLength(1);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('reset button resets the form', () => {
|
|
63
|
+
let formApi;
|
|
64
|
+
|
|
65
|
+
const { root } = createTestInstance(
|
|
66
|
+
<Form
|
|
67
|
+
getApi={api => {
|
|
68
|
+
formApi = api;
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<SearchField onChange={onChange} onFocus={onFocus} />
|
|
72
|
+
</Form>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
act(() => {
|
|
76
|
+
formApi.setValue('search_query', 'a');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const trigger = root.findByType(Trigger);
|
|
80
|
+
const { action: resetForm } = trigger.props;
|
|
81
|
+
|
|
82
|
+
act(() => {
|
|
83
|
+
resetForm();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(formApi.getValue('search_query')).toBeUndefined();
|
|
87
|
+
});
|
package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useLocation } from 'react-router-dom';
|
|
3
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
4
|
-
import SuggestedCategories from '../suggestedCategories';
|
|
5
|
-
import SuggestedCategory from '../suggestedCategory';
|
|
6
|
-
|
|
7
|
-
jest.mock('react-router-dom', () => ({
|
|
8
|
-
Link: jest.fn(() => null),
|
|
9
|
-
useLocation: jest.fn()
|
|
10
|
-
}));
|
|
11
|
-
jest.mock('../suggestedCategory', () => 'SuggestedCategory');
|
|
12
|
-
|
|
13
|
-
useLocation.mockReturnValue(globalThis.location);
|
|
14
|
-
|
|
15
|
-
const categories = [
|
|
16
|
-
{ label: 'A', value_string: 'a' },
|
|
17
|
-
{ label: 'B', value_string: 'b' },
|
|
18
|
-
{ label: 'C', value_string: 'c' },
|
|
19
|
-
{ label: 'D', value_string: 'd' },
|
|
20
|
-
{ label: 'E', value_string: 'e' }
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
test('renders correctly', () => {
|
|
24
|
-
const instance = createTestInstance(
|
|
25
|
-
<SuggestedCategories categories={categories} value="foo" />
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('renders a max of 4 categories by default', () => {
|
|
32
|
-
const { root } = createTestInstance(
|
|
33
|
-
<SuggestedCategories categories={categories} value="foo" />
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(root.findAllByType(SuggestedCategory)).toHaveLength(4);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('allows the render limit to be configured', () => {
|
|
40
|
-
const { root } = createTestInstance(
|
|
41
|
-
<SuggestedCategories categories={categories} limit={2} value="foo" />
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
expect(root.findAllByType(SuggestedCategory)).toHaveLength(2);
|
|
45
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
4
|
+
import SuggestedCategories from '../suggestedCategories';
|
|
5
|
+
import SuggestedCategory from '../suggestedCategory';
|
|
6
|
+
|
|
7
|
+
jest.mock('react-router-dom', () => ({
|
|
8
|
+
Link: jest.fn(() => null),
|
|
9
|
+
useLocation: jest.fn()
|
|
10
|
+
}));
|
|
11
|
+
jest.mock('../suggestedCategory', () => 'SuggestedCategory');
|
|
12
|
+
|
|
13
|
+
useLocation.mockReturnValue(globalThis.location);
|
|
14
|
+
|
|
15
|
+
const categories = [
|
|
16
|
+
{ label: 'A', value_string: 'a' },
|
|
17
|
+
{ label: 'B', value_string: 'b' },
|
|
18
|
+
{ label: 'C', value_string: 'c' },
|
|
19
|
+
{ label: 'D', value_string: 'd' },
|
|
20
|
+
{ label: 'E', value_string: 'e' }
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
test('renders correctly', () => {
|
|
24
|
+
const instance = createTestInstance(
|
|
25
|
+
<SuggestedCategories categories={categories} value="foo" />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('renders a max of 4 categories by default', () => {
|
|
32
|
+
const { root } = createTestInstance(
|
|
33
|
+
<SuggestedCategories categories={categories} value="foo" />
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(root.findAllByType(SuggestedCategory)).toHaveLength(4);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('allows the render limit to be configured', () => {
|
|
40
|
+
const { root } = createTestInstance(
|
|
41
|
+
<SuggestedCategories categories={categories} limit={2} value="foo" />
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
expect(root.findAllByType(SuggestedCategory)).toHaveLength(2);
|
|
45
|
+
});
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import TestRenderer from 'react-test-renderer';
|
|
3
|
-
import SuggestedProduct from '../suggestedProduct';
|
|
4
|
-
|
|
5
|
-
jest.mock('../../../classify');
|
|
6
|
-
jest.mock('react-router-dom', () => ({
|
|
7
|
-
Link: ({ children }) => children
|
|
8
|
-
}));
|
|
9
|
-
jest.mock('@magento/peregrine/lib/util/makeUrl');
|
|
10
|
-
jest.mock('@magento/peregrine/lib/context/eventing', () => ({
|
|
11
|
-
useEventingContext: jest.fn().mockReturnValue([{}, { dispatch: jest.fn() }])
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
const defaultProps = {
|
|
15
|
-
handleOnProductOpen: jest.fn(),
|
|
16
|
-
url_key: 'urlKey',
|
|
17
|
-
small_image: '/media/catalog/category/minimalist.jpg',
|
|
18
|
-
name: 'Product Name',
|
|
19
|
-
price: {
|
|
20
|
-
regularPrice: {
|
|
21
|
-
amount: {
|
|
22
|
-
currency: 'USD',
|
|
23
|
-
value: 3.5
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
price_range: {
|
|
28
|
-
maximum_price: {
|
|
29
|
-
final_price: {
|
|
30
|
-
currency: 'USD',
|
|
31
|
-
value: 3.5
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
test('renders a suggestedProduct component', () => {
|
|
38
|
-
const component = TestRenderer.create(
|
|
39
|
-
<SuggestedProduct {...defaultProps} />
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
expect(component.toJSON()).toMatchSnapshot();
|
|
43
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import TestRenderer from 'react-test-renderer';
|
|
3
|
+
import SuggestedProduct from '../suggestedProduct';
|
|
4
|
+
|
|
5
|
+
jest.mock('../../../classify');
|
|
6
|
+
jest.mock('react-router-dom', () => ({
|
|
7
|
+
Link: ({ children }) => children
|
|
8
|
+
}));
|
|
9
|
+
jest.mock('@magento/peregrine/lib/util/makeUrl');
|
|
10
|
+
jest.mock('@magento/peregrine/lib/context/eventing', () => ({
|
|
11
|
+
useEventingContext: jest.fn().mockReturnValue([{}, { dispatch: jest.fn() }])
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const defaultProps = {
|
|
15
|
+
handleOnProductOpen: jest.fn(),
|
|
16
|
+
url_key: 'urlKey',
|
|
17
|
+
small_image: '/media/catalog/category/minimalist.jpg',
|
|
18
|
+
name: 'Product Name',
|
|
19
|
+
price: {
|
|
20
|
+
regularPrice: {
|
|
21
|
+
amount: {
|
|
22
|
+
currency: 'USD',
|
|
23
|
+
value: 3.5
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
price_range: {
|
|
28
|
+
maximum_price: {
|
|
29
|
+
final_price: {
|
|
30
|
+
currency: 'USD',
|
|
31
|
+
value: 3.5
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
test('renders a suggestedProduct component', () => {
|
|
38
|
+
const component = TestRenderer.create(
|
|
39
|
+
<SuggestedProduct {...defaultProps} />
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
43
|
+
});
|
package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
-
|
|
4
|
-
import mapProduct from '../../../util/mapProduct';
|
|
5
|
-
import SuggestedProduct from '../suggestedProduct';
|
|
6
|
-
import SuggestedProducts from '../suggestedProducts';
|
|
7
|
-
|
|
8
|
-
jest.mock('../../../util/mapProduct', () => jest.fn());
|
|
9
|
-
jest.mock('../suggestedProduct', () => () => null);
|
|
10
|
-
|
|
11
|
-
const products = [{ id: 'a' }, { id: 'b' }, { id: 'c' }, { id: 'd' }];
|
|
12
|
-
|
|
13
|
-
test('renders correctly', () => {
|
|
14
|
-
const subset = products.slice(0, 1);
|
|
15
|
-
|
|
16
|
-
const instance = createTestInstance(
|
|
17
|
-
<SuggestedProducts products={subset} />
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('renders a max of 3 products by default', () => {
|
|
24
|
-
const { root } = createTestInstance(
|
|
25
|
-
<SuggestedProducts products={products} />
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
expect(root.findAllByType(SuggestedProduct)).toHaveLength(3);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('allows the render limit to be configured', () => {
|
|
32
|
-
const { root } = createTestInstance(
|
|
33
|
-
<SuggestedProducts limit={2} products={products} />
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(root.findAllByType(SuggestedProduct)).toHaveLength(2);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('calls `mapProduct()` for each item', () => {
|
|
40
|
-
createTestInstance(<SuggestedProducts limit={4} products={products} />);
|
|
41
|
-
|
|
42
|
-
products.forEach((product, index) => {
|
|
43
|
-
expect(mapProduct).toHaveBeenNthCalledWith(1 + index, product);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
|
|
4
|
+
import mapProduct from '../../../util/mapProduct';
|
|
5
|
+
import SuggestedProduct from '../suggestedProduct';
|
|
6
|
+
import SuggestedProducts from '../suggestedProducts';
|
|
7
|
+
|
|
8
|
+
jest.mock('../../../util/mapProduct', () => jest.fn());
|
|
9
|
+
jest.mock('../suggestedProduct', () => () => null);
|
|
10
|
+
|
|
11
|
+
const products = [{ id: 'a' }, { id: 'b' }, { id: 'c' }, { id: 'd' }];
|
|
12
|
+
|
|
13
|
+
test('renders correctly', () => {
|
|
14
|
+
const subset = products.slice(0, 1);
|
|
15
|
+
|
|
16
|
+
const instance = createTestInstance(
|
|
17
|
+
<SuggestedProducts products={subset} />
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('renders a max of 3 products by default', () => {
|
|
24
|
+
const { root } = createTestInstance(
|
|
25
|
+
<SuggestedProducts products={products} />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(root.findAllByType(SuggestedProduct)).toHaveLength(3);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('allows the render limit to be configured', () => {
|
|
32
|
+
const { root } = createTestInstance(
|
|
33
|
+
<SuggestedProducts limit={2} products={products} />
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(root.findAllByType(SuggestedProduct)).toHaveLength(2);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('calls `mapProduct()` for each item', () => {
|
|
40
|
+
createTestInstance(<SuggestedProducts limit={4} products={products} />);
|
|
41
|
+
|
|
42
|
+
products.forEach((product, index) => {
|
|
43
|
+
expect(mapProduct).toHaveBeenNthCalledWith(1 + index, product);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
-
|
|
4
|
-
import Suggestions from '../suggestions';
|
|
5
|
-
|
|
6
|
-
jest.mock('../suggestedCategories', () => () => null);
|
|
7
|
-
jest.mock('../suggestedProducts', () => () => null);
|
|
8
|
-
|
|
9
|
-
test('renders correctly', () => {
|
|
10
|
-
const products = {
|
|
11
|
-
items: [{}]
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const filters = [];
|
|
15
|
-
|
|
16
|
-
const instance = createTestInstance(
|
|
17
|
-
<Suggestions
|
|
18
|
-
displayResult={true}
|
|
19
|
-
filters={filters}
|
|
20
|
-
products={products}
|
|
21
|
-
visible={true}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('renders null if there are no items', () => {
|
|
29
|
-
const products = {
|
|
30
|
-
aggregations: [],
|
|
31
|
-
items: null
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const { root } = createTestInstance(
|
|
35
|
-
<Suggestions displayResult={true} products={products} visible={true} />
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
expect(root.children).toEqual([]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('renders null if displayResult is false', () => {
|
|
42
|
-
const products = {
|
|
43
|
-
aggregations: [],
|
|
44
|
-
items: []
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const { root } = createTestInstance(
|
|
48
|
-
<Suggestions displayResult={false} products={products} visible={true} />
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
expect(root.children).toEqual([]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('renders null if visible is false', () => {
|
|
55
|
-
const products = {
|
|
56
|
-
items: []
|
|
57
|
-
};
|
|
58
|
-
const filters = [];
|
|
59
|
-
|
|
60
|
-
const { root } = createTestInstance(
|
|
61
|
-
<Suggestions
|
|
62
|
-
displayResult={true}
|
|
63
|
-
filters={filters}
|
|
64
|
-
products={products}
|
|
65
|
-
visible={false}
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
expect(root.children).toEqual([]);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('renders null if items array is empty', () => {
|
|
73
|
-
const products = {
|
|
74
|
-
items: []
|
|
75
|
-
};
|
|
76
|
-
const filters = [];
|
|
77
|
-
|
|
78
|
-
const { root } = createTestInstance(
|
|
79
|
-
<Suggestions
|
|
80
|
-
displayResult={true}
|
|
81
|
-
filters={filters}
|
|
82
|
-
products={products}
|
|
83
|
-
visible={true}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
expect(root.children).toEqual([]);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('renders a category list', () => {
|
|
91
|
-
const filters = [
|
|
92
|
-
{ label: 'Color', options: [] },
|
|
93
|
-
{ label: 'Category', options: [] }
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
const products = {
|
|
97
|
-
items: [{}]
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const { root } = createTestInstance(
|
|
101
|
-
<Suggestions
|
|
102
|
-
displayResult={true}
|
|
103
|
-
filters={filters}
|
|
104
|
-
products={products}
|
|
105
|
-
visible={true}
|
|
106
|
-
/>
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
expect(root.findByProps({ categories: filters[1].options })).toBeTruthy();
|
|
110
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
|
|
4
|
+
import Suggestions from '../suggestions';
|
|
5
|
+
|
|
6
|
+
jest.mock('../suggestedCategories', () => () => null);
|
|
7
|
+
jest.mock('../suggestedProducts', () => () => null);
|
|
8
|
+
|
|
9
|
+
test('renders correctly', () => {
|
|
10
|
+
const products = {
|
|
11
|
+
items: [{}]
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const filters = [];
|
|
15
|
+
|
|
16
|
+
const instance = createTestInstance(
|
|
17
|
+
<Suggestions
|
|
18
|
+
displayResult={true}
|
|
19
|
+
filters={filters}
|
|
20
|
+
products={products}
|
|
21
|
+
visible={true}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('renders null if there are no items', () => {
|
|
29
|
+
const products = {
|
|
30
|
+
aggregations: [],
|
|
31
|
+
items: null
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const { root } = createTestInstance(
|
|
35
|
+
<Suggestions displayResult={true} products={products} visible={true} />
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expect(root.children).toEqual([]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('renders null if displayResult is false', () => {
|
|
42
|
+
const products = {
|
|
43
|
+
aggregations: [],
|
|
44
|
+
items: []
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const { root } = createTestInstance(
|
|
48
|
+
<Suggestions displayResult={false} products={products} visible={true} />
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
expect(root.children).toEqual([]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('renders null if visible is false', () => {
|
|
55
|
+
const products = {
|
|
56
|
+
items: []
|
|
57
|
+
};
|
|
58
|
+
const filters = [];
|
|
59
|
+
|
|
60
|
+
const { root } = createTestInstance(
|
|
61
|
+
<Suggestions
|
|
62
|
+
displayResult={true}
|
|
63
|
+
filters={filters}
|
|
64
|
+
products={products}
|
|
65
|
+
visible={false}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(root.children).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('renders null if items array is empty', () => {
|
|
73
|
+
const products = {
|
|
74
|
+
items: []
|
|
75
|
+
};
|
|
76
|
+
const filters = [];
|
|
77
|
+
|
|
78
|
+
const { root } = createTestInstance(
|
|
79
|
+
<Suggestions
|
|
80
|
+
displayResult={true}
|
|
81
|
+
filters={filters}
|
|
82
|
+
products={products}
|
|
83
|
+
visible={true}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(root.children).toEqual([]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('renders a category list', () => {
|
|
91
|
+
const filters = [
|
|
92
|
+
{ label: 'Color', options: [] },
|
|
93
|
+
{ label: 'Category', options: [] }
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const products = {
|
|
97
|
+
items: [{}]
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const { root } = createTestInstance(
|
|
101
|
+
<Suggestions
|
|
102
|
+
displayResult={true}
|
|
103
|
+
filters={filters}
|
|
104
|
+
products={products}
|
|
105
|
+
visible={true}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(root.findByProps({ categories: filters[1].options })).toBeTruthy();
|
|
110
|
+
});
|