@riosst100/pwa-marketplace 1.2.7 → 1.2.9
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 +42 -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 +166 -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,123 +1,123 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Link } from 'react-router-dom';
|
|
3
|
-
import { act } from 'react-test-renderer';
|
|
4
|
-
|
|
5
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
6
|
-
|
|
7
|
-
import MegaMenuItem from '../megaMenuItem';
|
|
8
|
-
|
|
9
|
-
jest.mock('../../../classify');
|
|
10
|
-
jest.mock('../../Icon', () => props => <mock-Icon {...props} />);
|
|
11
|
-
jest.mock('../submenu', () => props => <mock-Submenu {...props} />);
|
|
12
|
-
jest.mock('react', () => {
|
|
13
|
-
const React = jest.requireActual('react');
|
|
14
|
-
const memoSpy = jest.spyOn(React, 'useMemo');
|
|
15
|
-
|
|
16
|
-
return Object.assign(React, {
|
|
17
|
-
useMemo: memoSpy
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const mockHandleKeyDown = jest.fn();
|
|
22
|
-
|
|
23
|
-
jest.mock('react-router-dom', () => ({
|
|
24
|
-
Link: jest.fn(() => props => <mock-Link {...props} />)
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem', () => ({
|
|
28
|
-
useMegaMenuItem: jest.fn(() => {
|
|
29
|
-
return {
|
|
30
|
-
isFocused: false,
|
|
31
|
-
isActive: false,
|
|
32
|
-
handleMenuItemFocus: jest.fn(),
|
|
33
|
-
handleCloseSubMenu: jest.fn(),
|
|
34
|
-
isMenuActive: false,
|
|
35
|
-
handleKeyDown: mockHandleKeyDown
|
|
36
|
-
};
|
|
37
|
-
})
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
let inputProps = {};
|
|
41
|
-
|
|
42
|
-
const Component = () => {
|
|
43
|
-
return <MegaMenuItem {...inputProps} />;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const givenDefaultValues = () => {
|
|
47
|
-
inputProps = {
|
|
48
|
-
activeCategoryId: 1,
|
|
49
|
-
category: {
|
|
50
|
-
id: 1,
|
|
51
|
-
name: 'Women',
|
|
52
|
-
url_path: 'women',
|
|
53
|
-
isActive: true,
|
|
54
|
-
children: [
|
|
55
|
-
{
|
|
56
|
-
id: 2,
|
|
57
|
-
name: 'Bottoms',
|
|
58
|
-
url_path: 'bottoms',
|
|
59
|
-
children: []
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: 3,
|
|
63
|
-
name: 'Tops',
|
|
64
|
-
url_path: 'tops',
|
|
65
|
-
isActive: false,
|
|
66
|
-
children: []
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
rootCategoryName: 'Clothing',
|
|
71
|
-
categoryUrlSuffix: '.html',
|
|
72
|
-
mainNavWidth: 200,
|
|
73
|
-
subMenuState: 'test',
|
|
74
|
-
disableFocus: false
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
describe('Mega menu item renders correctly', () => {
|
|
79
|
-
beforeEach(() => {
|
|
80
|
-
givenDefaultValues();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('it renders correctly', () => {
|
|
84
|
-
const instance = createTestInstance(<Component />);
|
|
85
|
-
|
|
86
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('it marks the active category', () => {
|
|
90
|
-
const { root } = createTestInstance(<Component />);
|
|
91
|
-
|
|
92
|
-
expect(root.findByType(Link).props.className).toEqual('megaMenuLink');
|
|
93
|
-
expect(root.findByType(Link).props.to).toEqual('/women.html');
|
|
94
|
-
expect(root.findByType(Link).props.children[0]).toEqual('Women');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should call a11yClick', () => {
|
|
98
|
-
const { root } = createTestInstance(<Component />);
|
|
99
|
-
|
|
100
|
-
act(() => {
|
|
101
|
-
root.findByType(Link).props.onKeyDown();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(mockHandleKeyDown).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('it does not render submenu when item does not have children', () => {
|
|
108
|
-
const categoryWithoutChildren = {
|
|
109
|
-
id: 3,
|
|
110
|
-
name: 'Tops',
|
|
111
|
-
url_path: 'tops',
|
|
112
|
-
isActive: false,
|
|
113
|
-
children: []
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const instance = createTestInstance(
|
|
117
|
-
<Component category={categoryWithoutChildren} />
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
expect(instance.toJSON().children.length).toEqual(1);
|
|
121
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
122
|
-
});
|
|
123
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { act } from 'react-test-renderer';
|
|
4
|
+
|
|
5
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
6
|
+
|
|
7
|
+
import MegaMenuItem from '../megaMenuItem';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../classify');
|
|
10
|
+
jest.mock('../../Icon', () => props => <mock-Icon {...props} />);
|
|
11
|
+
jest.mock('../submenu', () => props => <mock-Submenu {...props} />);
|
|
12
|
+
jest.mock('react', () => {
|
|
13
|
+
const React = jest.requireActual('react');
|
|
14
|
+
const memoSpy = jest.spyOn(React, 'useMemo');
|
|
15
|
+
|
|
16
|
+
return Object.assign(React, {
|
|
17
|
+
useMemo: memoSpy
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const mockHandleKeyDown = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('react-router-dom', () => ({
|
|
24
|
+
Link: jest.fn(() => props => <mock-Link {...props} />)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem', () => ({
|
|
28
|
+
useMegaMenuItem: jest.fn(() => {
|
|
29
|
+
return {
|
|
30
|
+
isFocused: false,
|
|
31
|
+
isActive: false,
|
|
32
|
+
handleMenuItemFocus: jest.fn(),
|
|
33
|
+
handleCloseSubMenu: jest.fn(),
|
|
34
|
+
isMenuActive: false,
|
|
35
|
+
handleKeyDown: mockHandleKeyDown
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
let inputProps = {};
|
|
41
|
+
|
|
42
|
+
const Component = () => {
|
|
43
|
+
return <MegaMenuItem {...inputProps} />;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const givenDefaultValues = () => {
|
|
47
|
+
inputProps = {
|
|
48
|
+
activeCategoryId: 1,
|
|
49
|
+
category: {
|
|
50
|
+
id: 1,
|
|
51
|
+
name: 'Women',
|
|
52
|
+
url_path: 'women',
|
|
53
|
+
isActive: true,
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
name: 'Bottoms',
|
|
58
|
+
url_path: 'bottoms',
|
|
59
|
+
children: []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 3,
|
|
63
|
+
name: 'Tops',
|
|
64
|
+
url_path: 'tops',
|
|
65
|
+
isActive: false,
|
|
66
|
+
children: []
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
rootCategoryName: 'Clothing',
|
|
71
|
+
categoryUrlSuffix: '.html',
|
|
72
|
+
mainNavWidth: 200,
|
|
73
|
+
subMenuState: 'test',
|
|
74
|
+
disableFocus: false
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
describe('Mega menu item renders correctly', () => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
givenDefaultValues();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('it renders correctly', () => {
|
|
84
|
+
const instance = createTestInstance(<Component />);
|
|
85
|
+
|
|
86
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('it marks the active category', () => {
|
|
90
|
+
const { root } = createTestInstance(<Component />);
|
|
91
|
+
|
|
92
|
+
expect(root.findByType(Link).props.className).toEqual('megaMenuLink');
|
|
93
|
+
expect(root.findByType(Link).props.to).toEqual('/women.html');
|
|
94
|
+
expect(root.findByType(Link).props.children[0]).toEqual('Women');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should call a11yClick', () => {
|
|
98
|
+
const { root } = createTestInstance(<Component />);
|
|
99
|
+
|
|
100
|
+
act(() => {
|
|
101
|
+
root.findByType(Link).props.onKeyDown();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(mockHandleKeyDown).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('it does not render submenu when item does not have children', () => {
|
|
108
|
+
const categoryWithoutChildren = {
|
|
109
|
+
id: 3,
|
|
110
|
+
name: 'Tops',
|
|
111
|
+
url_path: 'tops',
|
|
112
|
+
isActive: false,
|
|
113
|
+
children: []
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const instance = createTestInstance(
|
|
117
|
+
<Component category={categoryWithoutChildren} />
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(instance.toJSON().children.length).toEqual(1);
|
|
121
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
|
|
5
|
-
import Submenu from '../submenu';
|
|
6
|
-
|
|
7
|
-
jest.mock('../../../classify');
|
|
8
|
-
jest.mock('../submenuColumn', () => props => <mock-SubmenuColumn {...props} />);
|
|
9
|
-
jest.mock('react', () => {
|
|
10
|
-
const React = jest.requireActual('react');
|
|
11
|
-
const callbackSpy = jest.spyOn(React, 'useCallback');
|
|
12
|
-
|
|
13
|
-
return Object.assign(React, {
|
|
14
|
-
callbackSpy: callbackSpy
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const handleCloseSubMenu = jest.fn().mockName('handleCloseSubMenu');
|
|
19
|
-
|
|
20
|
-
describe('Submenu renders correctly', () => {
|
|
21
|
-
const props = {
|
|
22
|
-
items: [
|
|
23
|
-
{
|
|
24
|
-
id: 1,
|
|
25
|
-
name: 'Bottoms',
|
|
26
|
-
url_path: 'bottoms',
|
|
27
|
-
children: [
|
|
28
|
-
{
|
|
29
|
-
id: 3,
|
|
30
|
-
name: 'Pants',
|
|
31
|
-
url_path: 'pants',
|
|
32
|
-
isActive: false,
|
|
33
|
-
children: []
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 2,
|
|
39
|
-
name: 'Tops',
|
|
40
|
-
url_path: 'tops',
|
|
41
|
-
isActive: false,
|
|
42
|
-
children: []
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
rootCategoryName: 'Clothing',
|
|
46
|
-
firstLevelCategoryName: 'Women',
|
|
47
|
-
categoryUrlSuffix: '.html',
|
|
48
|
-
handleCloseSubMenu,
|
|
49
|
-
isFocused: false,
|
|
50
|
-
subMenuState: false
|
|
51
|
-
};
|
|
52
|
-
test('it renders correctly', () => {
|
|
53
|
-
const instance = createTestInstance(
|
|
54
|
-
<MemoryRouter>
|
|
55
|
-
<Submenu {...props} />
|
|
56
|
-
</MemoryRouter>
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import Submenu from '../submenu';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
jest.mock('../submenuColumn', () => props => <mock-SubmenuColumn {...props} />);
|
|
9
|
+
jest.mock('react', () => {
|
|
10
|
+
const React = jest.requireActual('react');
|
|
11
|
+
const callbackSpy = jest.spyOn(React, 'useCallback');
|
|
12
|
+
|
|
13
|
+
return Object.assign(React, {
|
|
14
|
+
callbackSpy: callbackSpy
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const handleCloseSubMenu = jest.fn().mockName('handleCloseSubMenu');
|
|
19
|
+
|
|
20
|
+
describe('Submenu renders correctly', () => {
|
|
21
|
+
const props = {
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
id: 1,
|
|
25
|
+
name: 'Bottoms',
|
|
26
|
+
url_path: 'bottoms',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
id: 3,
|
|
30
|
+
name: 'Pants',
|
|
31
|
+
url_path: 'pants',
|
|
32
|
+
isActive: false,
|
|
33
|
+
children: []
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 2,
|
|
39
|
+
name: 'Tops',
|
|
40
|
+
url_path: 'tops',
|
|
41
|
+
isActive: false,
|
|
42
|
+
children: []
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
rootCategoryName: 'Clothing',
|
|
46
|
+
firstLevelCategoryName: 'Women',
|
|
47
|
+
categoryUrlSuffix: '.html',
|
|
48
|
+
handleCloseSubMenu,
|
|
49
|
+
isFocused: false,
|
|
50
|
+
subMenuState: false
|
|
51
|
+
};
|
|
52
|
+
test('it renders correctly', () => {
|
|
53
|
+
const instance = createTestInstance(
|
|
54
|
+
<MemoryRouter>
|
|
55
|
+
<Submenu {...props} />
|
|
56
|
+
</MemoryRouter>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
|
|
5
|
-
import SubmenuColumn from '../submenuColumn';
|
|
6
|
-
|
|
7
|
-
jest.mock('../../../classify');
|
|
8
|
-
|
|
9
|
-
describe('Submenu column renders correctly', () => {
|
|
10
|
-
const props = {
|
|
11
|
-
category: {
|
|
12
|
-
id: 1,
|
|
13
|
-
name: 'Pants',
|
|
14
|
-
url_path: 'pants',
|
|
15
|
-
children: [
|
|
16
|
-
{
|
|
17
|
-
id: 2,
|
|
18
|
-
name: 'Jeans',
|
|
19
|
-
url_path: 'jeans',
|
|
20
|
-
isActive: true,
|
|
21
|
-
children: []
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
categoryUrlSuffix: '.html'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
test('it renders correctly', () => {
|
|
29
|
-
const instance = createTestInstance(
|
|
30
|
-
<MemoryRouter>
|
|
31
|
-
<SubmenuColumn {...props} />
|
|
32
|
-
</MemoryRouter>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
expect(instance.toJSON()).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('it renders active state', () => {
|
|
39
|
-
const instance = createTestInstance(
|
|
40
|
-
<MemoryRouter>
|
|
41
|
-
<SubmenuColumn {...props} />
|
|
42
|
-
</MemoryRouter>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const activeLink = instance.root.findByProps({
|
|
46
|
-
className: 'linkActive'
|
|
47
|
-
});
|
|
48
|
-
expect(activeLink.props.children).toEqual('Jeans');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import SubmenuColumn from '../submenuColumn';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
|
|
9
|
+
describe('Submenu column renders correctly', () => {
|
|
10
|
+
const props = {
|
|
11
|
+
category: {
|
|
12
|
+
id: 1,
|
|
13
|
+
name: 'Pants',
|
|
14
|
+
url_path: 'pants',
|
|
15
|
+
children: [
|
|
16
|
+
{
|
|
17
|
+
id: 2,
|
|
18
|
+
name: 'Jeans',
|
|
19
|
+
url_path: 'jeans',
|
|
20
|
+
isActive: true,
|
|
21
|
+
children: []
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
categoryUrlSuffix: '.html'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
test('it renders correctly', () => {
|
|
29
|
+
const instance = createTestInstance(
|
|
30
|
+
<MemoryRouter>
|
|
31
|
+
<SubmenuColumn {...props} />
|
|
32
|
+
</MemoryRouter>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('it renders active state', () => {
|
|
39
|
+
const instance = createTestInstance(
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<SubmenuColumn {...props} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const activeLink = instance.root.findByProps({
|
|
46
|
+
className: 'linkActive'
|
|
47
|
+
});
|
|
48
|
+
expect(activeLink.props.children).toEqual('Jeans');
|
|
49
|
+
});
|
|
50
|
+
});
|