@shopgate/pwa-ui-shared 7.32.0-beta.2 → 7.32.0-beta.21
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/ActionButton/index.js +4 -0
- package/AddToCartButton/index.js +4 -1
- package/Button/index.js +10 -3
- package/ButtonLink/index.js +4 -0
- package/Card/index.js +13 -34
- package/CardList/components/Item/index.js +26 -20
- package/CardList/index.js +2 -1
- package/CartTotalLine/index.js +1 -1
- package/Dialog/components/PipelineErrorDialog/index.js +2 -1
- package/DiscountBadge/index.js +1 -1
- package/FavoritesButton/FavoritesButton.d.ts +74 -0
- package/FavoritesButton/FavoritesButton.d.ts.map +1 -0
- package/FavoritesButton/FavoritesButton.js +87 -0
- package/FavoritesButton/connector.d.ts +3 -0
- package/FavoritesButton/connector.d.ts.map +1 -0
- package/FavoritesButton/index.d.ts +3 -0
- package/FavoritesButton/index.d.ts.map +1 -0
- package/FavoritesButton/index.js +1 -134
- package/Glow/index.js +4 -3
- package/NoResults/components/Icon/index.js +4 -1
- package/NoResults/index.js +1 -1
- package/Price/index.js +11 -4
- package/PriceStriked/index.js +7 -1
- package/RatingStars/index.js +16 -5
- package/RippleButton/index.js +5 -1
- package/Sheet/index.js +11 -1
- package/TaxDisclaimer/index.js +0 -1
- package/package.json +5 -5
- package/AccordionContainer/spec.js +0 -35
- package/ActionButton/spec.js +0 -66
- package/AddToCartButton/spec.js +0 -68
- package/Availability/spec.js +0 -42
- package/Button/spec.js +0 -38
- package/ButtonLink/spec.js +0 -29
- package/Chip/spec.js +0 -27
- package/ContextMenu/spec.js +0 -113
- package/Dialog/components/HtmlContentDialog/spec.js +0 -107
- package/Dialog/components/PipelineErrorDialog/spec.js +0 -89
- package/Dialog/components/TextMessageDialog/spec.js +0 -62
- package/Dialog/components/VariantSelectModal/spec.js +0 -55
- package/Dialog/spec.js +0 -84
- package/DiscountBadge/spec.js +0 -20
- package/FavoritesButton/spec.js +0 -131
- package/Form/Builder/classes/ActionListener/spec.js +0 -323
- package/Form/Builder/spec.js +0 -309
- package/Form/InfoField/spec.js +0 -12
- package/Form/Password/spec.js +0 -39
- package/Form/RadioGroup/spec.js +0 -97
- package/Form/Select/spec.js +0 -39
- package/Form/SelectContextChoices/spec.js +0 -36
- package/Form/TextField/spec.js +0 -124
- package/FormElement/spec.js +0 -68
- package/Glow/spec.js +0 -14
- package/IndicatorCircle/spec.js +0 -26
- package/PlaceholderLabel/spec.js +0 -26
- package/PlaceholderParagraph/spec.js +0 -26
- package/ProgressBar/spec.js +0 -14
- package/RadioButton/spec.js +0 -22
- package/RatingStars/spec.js +0 -91
- package/RippleButton/spec.js +0 -58
- package/Sheet/components/Header/components/SearchBar/spec.js +0 -22
- package/Sheet/components/Header/spec.js +0 -17
- package/Sheet/spec.js +0 -100
- package/TaxDisclaimer/spec.js +0 -44
- package/TextField/spec.js +0 -146
- package/ToggleIcon/spec.js +0 -39
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -3
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from 'enzyme';
|
|
3
|
-
import PipelineErrorDialog from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
6
|
-
describe('<PipelineErrorDialog />', () => {
|
|
7
|
-
const defaultParams = {
|
|
8
|
-
code: '123',
|
|
9
|
-
message: 'Error message',
|
|
10
|
-
pipeline: 'fakePipeline',
|
|
11
|
-
request: {}
|
|
12
|
-
};
|
|
13
|
-
it('should render with minimal props', () => {
|
|
14
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
15
|
-
actions: [],
|
|
16
|
-
params: defaultParams
|
|
17
|
-
}));
|
|
18
|
-
expect(wrapper).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
it('should show a custom message if a message is is provided', () => {
|
|
21
|
-
const message = 'Custom message';
|
|
22
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
23
|
-
actions: [],
|
|
24
|
-
message: message,
|
|
25
|
-
params: defaultParams
|
|
26
|
-
}));
|
|
27
|
-
expect(wrapper).toMatchSnapshot();
|
|
28
|
-
expect(wrapper.html()).toMatch(message);
|
|
29
|
-
});
|
|
30
|
-
it('should switch modes on tap', () => {
|
|
31
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
32
|
-
actions: [],
|
|
33
|
-
params: defaultParams
|
|
34
|
-
}));
|
|
35
|
-
const numTaps = 10;
|
|
36
|
-
const clickElement = wrapper.find('div[onClick]');
|
|
37
|
-
const devMarker = 'Pipeline:';
|
|
38
|
-
|
|
39
|
-
// Dev mode should be disabled.
|
|
40
|
-
for (let i = 0; i < numTaps; i += 1) {
|
|
41
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
42
|
-
clickElement.simulate('click');
|
|
43
|
-
}
|
|
44
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
45
|
-
|
|
46
|
-
// Dev mode should be enabled until 10 more taps.
|
|
47
|
-
for (let i = 0; i < numTaps - 1; i += 1) {
|
|
48
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
49
|
-
clickElement.simulate('click');
|
|
50
|
-
}
|
|
51
|
-
clickElement.simulate('click');
|
|
52
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
53
|
-
});
|
|
54
|
-
it('should not switch modes if tapped too slow', () => {
|
|
55
|
-
jest.useFakeTimers();
|
|
56
|
-
const wrapper = mount(/*#__PURE__*/_jsx(PipelineErrorDialog, {
|
|
57
|
-
actions: [],
|
|
58
|
-
params: defaultParams
|
|
59
|
-
}));
|
|
60
|
-
const numTaps = 10;
|
|
61
|
-
const numTapsUntilTimeout = Math.round(numTaps / 2);
|
|
62
|
-
const clickElement = wrapper.find('div[onClick]');
|
|
63
|
-
const devMarker = 'Pipeline:';
|
|
64
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Simulates multiple tap events.
|
|
68
|
-
* @param {number} amount The number of tap events to simulate in a row.
|
|
69
|
-
*/
|
|
70
|
-
const tapOnElement = amount => {
|
|
71
|
-
if (amount > 0) {
|
|
72
|
-
clickElement.simulate('click');
|
|
73
|
-
tapOnElement(amount - 1);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Tap a few times.
|
|
78
|
-
tapOnElement(numTapsUntilTimeout);
|
|
79
|
-
|
|
80
|
-
// Trigger a timeout (user was too slow).
|
|
81
|
-
jest.runAllTimers();
|
|
82
|
-
|
|
83
|
-
// Tap the remaining times.
|
|
84
|
-
tapOnElement(numTaps - numTapsUntilTimeout);
|
|
85
|
-
expect(wrapper.text()).not.toContain(devMarker);
|
|
86
|
-
tapOnElement(numTapsUntilTimeout);
|
|
87
|
-
expect(wrapper.text()).toContain(devMarker);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import TextMessageDialog from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const message = 'This is the message.';
|
|
6
|
-
const title = 'This is the title.';
|
|
7
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
8
|
-
describe('<TextMessageDialog />', () => {
|
|
9
|
-
it('should render with minimal props', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
11
|
-
message: message,
|
|
12
|
-
actions: []
|
|
13
|
-
}));
|
|
14
|
-
expect(wrapper).toMatchSnapshot();
|
|
15
|
-
expect(wrapper.html()).toMatch(message);
|
|
16
|
-
});
|
|
17
|
-
it('should render with title and message', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
19
|
-
title: title,
|
|
20
|
-
message: message,
|
|
21
|
-
actions: []
|
|
22
|
-
}));
|
|
23
|
-
expect(wrapper).toMatchSnapshot();
|
|
24
|
-
expect(wrapper.html()).toMatch(title);
|
|
25
|
-
});
|
|
26
|
-
it('should render with title, message and messageParams', () => {
|
|
27
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
28
|
-
title: title,
|
|
29
|
-
message: "Message with {name}",
|
|
30
|
-
params: {
|
|
31
|
-
name: 'Placeholder'
|
|
32
|
-
},
|
|
33
|
-
actions: []
|
|
34
|
-
}));
|
|
35
|
-
expect(wrapper).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
it('should render the actions', () => {
|
|
38
|
-
const actions = [{
|
|
39
|
-
label: 'fooAction',
|
|
40
|
-
action: () => {}
|
|
41
|
-
}];
|
|
42
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
43
|
-
title: title,
|
|
44
|
-
message: message,
|
|
45
|
-
actions: actions
|
|
46
|
-
}));
|
|
47
|
-
expect(wrapper).toMatchSnapshot();
|
|
48
|
-
expect(wrapper.html()).toMatch(actions[0].label);
|
|
49
|
-
});
|
|
50
|
-
it('should pass title through', () => {
|
|
51
|
-
const customTitle = /*#__PURE__*/_jsx("div", {
|
|
52
|
-
children: "Title"
|
|
53
|
-
});
|
|
54
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(TextMessageDialog, {
|
|
55
|
-
title: customTitle,
|
|
56
|
-
message: message,
|
|
57
|
-
params: {},
|
|
58
|
-
actions: []
|
|
59
|
-
}));
|
|
60
|
-
expect(wrapper.find('BasicDialog').prop('title')).toEqual(customTitle);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { UnwrappedVariantSelectModal as VariantSelectModal } from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const message = 'This is the message.';
|
|
6
|
-
const title = 'This is the title.';
|
|
7
|
-
jest.mock('@shopgate/engage/a11y/components');
|
|
8
|
-
describe('<VariantSelectModal />', () => {
|
|
9
|
-
it('should render with minimal props', () => {
|
|
10
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
11
|
-
message: message,
|
|
12
|
-
actions: [],
|
|
13
|
-
navigate: () => {}
|
|
14
|
-
}));
|
|
15
|
-
expect(wrapper).toMatchSnapshot();
|
|
16
|
-
expect(wrapper.html()).toMatch(message);
|
|
17
|
-
});
|
|
18
|
-
it('should render the actions', () => {
|
|
19
|
-
const mockConfirm = jest.fn();
|
|
20
|
-
const mockNavigate = jest.fn();
|
|
21
|
-
/**
|
|
22
|
-
* Mocks named function
|
|
23
|
-
*/
|
|
24
|
-
const onConfirm = () => {
|
|
25
|
-
mockConfirm();
|
|
26
|
-
};
|
|
27
|
-
const actions = [{
|
|
28
|
-
label: 'confirm',
|
|
29
|
-
action: onConfirm
|
|
30
|
-
}, {
|
|
31
|
-
label: 'dismiss',
|
|
32
|
-
action: () => {}
|
|
33
|
-
}];
|
|
34
|
-
const params = {
|
|
35
|
-
productId: 'product_1'
|
|
36
|
-
};
|
|
37
|
-
const mockedProps = {
|
|
38
|
-
message,
|
|
39
|
-
title,
|
|
40
|
-
params,
|
|
41
|
-
actions: [].concat(actions),
|
|
42
|
-
navigate: mockNavigate
|
|
43
|
-
};
|
|
44
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(VariantSelectModal, {
|
|
45
|
-
...mockedProps
|
|
46
|
-
}));
|
|
47
|
-
expect(wrapper).toMatchSnapshot();
|
|
48
|
-
const reordered = wrapper.find('BasicDialog').props().actions;
|
|
49
|
-
const last = reordered.slice(-1)[0];
|
|
50
|
-
expect(last.label).toEqual(actions[0].label);
|
|
51
|
-
last.action();
|
|
52
|
-
expect(mockConfirm).toHaveBeenCalledTimes(1);
|
|
53
|
-
expect(mockNavigate).toHaveBeenCalledTimes(1);
|
|
54
|
-
});
|
|
55
|
-
});
|
package/Dialog/spec.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, ReactWrapper } from 'enzyme';
|
|
3
|
-
import { MODAL_PIPELINE_ERROR } from '@shopgate/pwa-common/constants/ModalTypes';
|
|
4
|
-
import { MODAL_VARIANT_SELECT } from "./constants";
|
|
5
|
-
import Dialog from "./index";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
jest.mock("./components/VariantSelectModal", () => {
|
|
8
|
-
/**
|
|
9
|
-
* VariantSelectModal mock.
|
|
10
|
-
* @return {JSX}
|
|
11
|
-
*/
|
|
12
|
-
const VariantSelectModal = () => /*#__PURE__*/_jsx("div", {});
|
|
13
|
-
return VariantSelectModal;
|
|
14
|
-
});
|
|
15
|
-
jest.mock('@shopgate/engage/components');
|
|
16
|
-
describe('<Dialog />', () => {
|
|
17
|
-
it('should render without props', () => {
|
|
18
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
19
|
-
modal: {
|
|
20
|
-
message: 'msg'
|
|
21
|
-
}
|
|
22
|
-
}));
|
|
23
|
-
expect(wrapper).toMatchSnapshot();
|
|
24
|
-
expect(wrapper.find('TextMessageDialog').length).toBe(1);
|
|
25
|
-
});
|
|
26
|
-
it('should render BasicDialog when no message given', () => {
|
|
27
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
28
|
-
modal: {
|
|
29
|
-
message: null
|
|
30
|
-
}
|
|
31
|
-
}));
|
|
32
|
-
expect(wrapper).toMatchSnapshot();
|
|
33
|
-
expect(wrapper.find('BasicDialog').length).toBe(1);
|
|
34
|
-
});
|
|
35
|
-
it('should render a special dialog', () => {
|
|
36
|
-
const params = {
|
|
37
|
-
errorCode: '',
|
|
38
|
-
message: '',
|
|
39
|
-
pipeline: '',
|
|
40
|
-
request: {}
|
|
41
|
-
};
|
|
42
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
43
|
-
modal: {
|
|
44
|
-
type: MODAL_PIPELINE_ERROR,
|
|
45
|
-
params
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
expect(wrapper).toMatchSnapshot();
|
|
49
|
-
expect(wrapper.find('DefaultDialog').length).toBe(0);
|
|
50
|
-
expect(wrapper.find('PipelineErrorDialog').length).toBe(1);
|
|
51
|
-
});
|
|
52
|
-
it('should render variant select dialog', () => {
|
|
53
|
-
const params = {
|
|
54
|
-
productId: 'product_1'
|
|
55
|
-
};
|
|
56
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
57
|
-
modal: {
|
|
58
|
-
message: 'Test',
|
|
59
|
-
type: MODAL_VARIANT_SELECT,
|
|
60
|
-
params
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
expect(wrapper).toMatchSnapshot();
|
|
64
|
-
expect(wrapper.find('DefaultDialog').length).toBe(0);
|
|
65
|
-
expect(wrapper.find('VariantSelectModal').length).toBe(1);
|
|
66
|
-
});
|
|
67
|
-
it('should convert title into translatable element', () => {
|
|
68
|
-
const title = 'translate.me';
|
|
69
|
-
const titleParams = {
|
|
70
|
-
foo: 'bar'
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// eslint-disable-next-line extra-rules/no-single-line-objects
|
|
74
|
-
const wrapper = shallow(/*#__PURE__*/_jsx(Dialog, {
|
|
75
|
-
modal: {
|
|
76
|
-
title,
|
|
77
|
-
titleParams
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
const i18n = new ReactWrapper(wrapper.find('BasicDialog').prop('title'));
|
|
81
|
-
expect(i18n.prop('string')).toEqual(title);
|
|
82
|
-
expect(i18n.prop('params')).toEqual(titleParams);
|
|
83
|
-
});
|
|
84
|
-
});
|
package/DiscountBadge/spec.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import DiscountBadge from "./index";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
jest.mock('@shopgate/engage/components');
|
|
6
|
-
describe('<DiscountBadge />', () => {
|
|
7
|
-
it('should render the text', () => {
|
|
8
|
-
const wrapper = render(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
9
|
-
text: "foo"
|
|
10
|
-
}));
|
|
11
|
-
expect(wrapper.asFragment()).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
it('should render the text and discount', () => {
|
|
14
|
-
const wrapper = render(/*#__PURE__*/_jsx(DiscountBadge, {
|
|
15
|
-
text: "SAVE {0}%",
|
|
16
|
-
discount: 20
|
|
17
|
-
}));
|
|
18
|
-
expect(wrapper.asFragment()).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
});
|
package/FavoritesButton/spec.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act } from 'react-dom/test-utils';
|
|
3
|
-
import { Provider } from 'react-redux';
|
|
4
|
-
import configureStore from 'redux-mock-store';
|
|
5
|
-
import { mount } from 'enzyme';
|
|
6
|
-
import mockRenderOptions from '@shopgate/pwa-common/helpers/mocks/mockRenderOptions';
|
|
7
|
-
import appConfig from '@shopgate/pwa-common/helpers/config';
|
|
8
|
-
import FavoritesButton from "./index";
|
|
9
|
-
import { mockedStateEmpty, mockedStateOnList, mockedStateNotOnList } from "./mock";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const mockedStore = configureStore();
|
|
12
|
-
const dispatcher = jest.fn();
|
|
13
|
-
jest.mock('@shopgate/pwa-common/helpers/config');
|
|
14
|
-
jest.mock('@shopgate/pwa-common-commerce/favorites/selectors/index', () => ({
|
|
15
|
-
isFetching: () => false
|
|
16
|
-
}));
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.resetModules();
|
|
19
|
-
});
|
|
20
|
-
describe('<FavoritesButton />', () => {
|
|
21
|
-
let component = null;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates component with provided store state.
|
|
25
|
-
* @param {Object} mockedState Mocked stage.
|
|
26
|
-
* @param {Object} props Additional props.
|
|
27
|
-
* @return {ReactWrapper}
|
|
28
|
-
*/
|
|
29
|
-
const createComponent = (mockedState, props = {
|
|
30
|
-
active: false
|
|
31
|
-
}) => {
|
|
32
|
-
const store = mockedStore(mockedState);
|
|
33
|
-
store.dispatch = dispatcher;
|
|
34
|
-
return mount(/*#__PURE__*/_jsx(Provider, {
|
|
35
|
-
store: store,
|
|
36
|
-
children: /*#__PURE__*/_jsx(FavoritesButton, {
|
|
37
|
-
...props
|
|
38
|
-
})
|
|
39
|
-
}), mockRenderOptions);
|
|
40
|
-
};
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
dispatcher.mockReset();
|
|
43
|
-
});
|
|
44
|
-
it('should only render when no favorites set', () => {
|
|
45
|
-
component = createComponent(mockedStateEmpty);
|
|
46
|
-
expect(component).toMatchSnapshot();
|
|
47
|
-
expect(component.find('Heart').exists()).toBe(false);
|
|
48
|
-
expect(component.find('HeartOutline').exists()).toBe(true);
|
|
49
|
-
component.find('button').simulate('click');
|
|
50
|
-
});
|
|
51
|
-
it('should render when favorites set', () => {
|
|
52
|
-
component = createComponent(mockedStateOnList, {
|
|
53
|
-
active: true
|
|
54
|
-
});
|
|
55
|
-
expect(component).toMatchSnapshot();
|
|
56
|
-
expect(component.find('Heart').exists()).toBe(true);
|
|
57
|
-
expect(component.find('HeartOutline').exists()).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
it('should add to favorites on click', () => {
|
|
60
|
-
component = createComponent(mockedStateNotOnList, {
|
|
61
|
-
productId: '1',
|
|
62
|
-
active: false
|
|
63
|
-
});
|
|
64
|
-
expect(component.find('Heart').exists()).toBe(false);
|
|
65
|
-
expect(component.find('HeartOutline').exists()).toBe(true);
|
|
66
|
-
component.find('button').simulate('click');
|
|
67
|
-
component.update();
|
|
68
|
-
expect(dispatcher).toHaveBeenCalled();
|
|
69
|
-
});
|
|
70
|
-
it('should remove from favorites on click', done => {
|
|
71
|
-
component = createComponent(mockedStateOnList, {
|
|
72
|
-
productId: '1',
|
|
73
|
-
active: true
|
|
74
|
-
});
|
|
75
|
-
expect(component.find('Heart').exists()).toBe(true);
|
|
76
|
-
expect(component.find('HeartOutline').exists()).toBe(false);
|
|
77
|
-
component.find('button').simulate('click');
|
|
78
|
-
component.update();
|
|
79
|
-
setTimeout(() => {
|
|
80
|
-
expect(dispatcher).toHaveBeenCalled();
|
|
81
|
-
done();
|
|
82
|
-
}, 0);
|
|
83
|
-
});
|
|
84
|
-
it('should process ripple complete callback', async () => {
|
|
85
|
-
const onRippleComplete = jest.fn();
|
|
86
|
-
component = createComponent(mockedStateOnList, {
|
|
87
|
-
productId: '1',
|
|
88
|
-
active: true,
|
|
89
|
-
onRippleComplete
|
|
90
|
-
});
|
|
91
|
-
await act(async () => {
|
|
92
|
-
component.find('Ripple').invoke('onComplete')();
|
|
93
|
-
});
|
|
94
|
-
component.update();
|
|
95
|
-
expect(onRippleComplete).toHaveBeenCalled();
|
|
96
|
-
});
|
|
97
|
-
it('should only react on first click', done => {
|
|
98
|
-
component = createComponent(mockedStateOnList, {
|
|
99
|
-
once: true,
|
|
100
|
-
productId: '1',
|
|
101
|
-
active: false
|
|
102
|
-
});
|
|
103
|
-
component.find('button').simulate('click');
|
|
104
|
-
component.update();
|
|
105
|
-
component.find('button').simulate('click');
|
|
106
|
-
component.update();
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
expect(dispatcher.mock.calls.length).toBe(1);
|
|
109
|
-
done();
|
|
110
|
-
}, 1);
|
|
111
|
-
});
|
|
112
|
-
it('should only react on both clicks', done => {
|
|
113
|
-
component = createComponent(mockedStateOnList, {
|
|
114
|
-
productId: '1',
|
|
115
|
-
active: false
|
|
116
|
-
});
|
|
117
|
-
component.find('button').simulate('click');
|
|
118
|
-
component.update();
|
|
119
|
-
component.find('button').simulate('click');
|
|
120
|
-
component.update();
|
|
121
|
-
setTimeout(() => {
|
|
122
|
-
expect(dispatcher.mock.calls.length).toBe(2);
|
|
123
|
-
done();
|
|
124
|
-
}, 1);
|
|
125
|
-
});
|
|
126
|
-
it('should render null when feature flag is off', () => {
|
|
127
|
-
jest.spyOn(appConfig, 'hasFavorites', 'get').mockReturnValue(false);
|
|
128
|
-
component = createComponent(mockedStateOnList);
|
|
129
|
-
expect(component.isEmptyRender()).toBe(true);
|
|
130
|
-
});
|
|
131
|
-
});
|