@capillarytech/creatives-library 8.0.242-alpha.0 → 8.0.242-alpha.10
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/assets/Android.png +0 -0
- package/assets/iOS.png +0 -0
- package/constants/unified.js +2 -1
- package/initialReducer.js +2 -0
- package/package.json +1 -1
- package/sagas/__tests__/assetPolling.test.js +74 -3
- package/sagas/assetPolling.js +8 -1
- package/services/api.js +10 -5
- package/services/tests/api.test.js +18 -0
- package/translations/en.json +0 -1
- package/utils/common.js +5 -0
- package/utils/commonUtils.js +14 -1
- package/utils/tests/commonUtil.test.js +224 -0
- package/utils/transformTemplateConfig.js +0 -10
- package/utils/transformerUtils.js +0 -42
- package/v2Components/CapDeviceContent/index.js +61 -56
- package/v2Components/CapImageUpload/constants.js +0 -2
- package/v2Components/CapImageUpload/index.js +14 -54
- package/v2Components/CapImageUpload/index.scss +1 -4
- package/v2Components/CapImageUpload/messages.js +0 -4
- package/v2Components/CapTagList/index.js +6 -1
- package/v2Components/CapTagListWithInput/index.js +5 -1
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/CapWhatsappCTA/tests/index.test.js +5 -0
- package/v2Components/ErrorInfoNote/index.js +412 -72
- package/v2Components/ErrorInfoNote/messages.js +22 -0
- package/v2Components/ErrorInfoNote/style.scss +279 -2
- package/v2Components/HtmlEditor/HTMLEditor.js +220 -91
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1132 -133
- package/v2Components/HtmlEditor/__tests__/index.lazy.test.js +17 -12
- package/v2Components/HtmlEditor/_htmlEditor.scss +107 -45
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +13 -101
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +148 -139
- package/v2Components/HtmlEditor/components/DeviceToggle/_deviceToggle.scss +2 -1
- package/v2Components/HtmlEditor/components/DeviceToggle/index.js +3 -3
- package/v2Components/HtmlEditor/components/EditorToolbar/_editorToolbar.scss +9 -0
- package/v2Components/HtmlEditor/components/EditorToolbar/index.js +1 -1
- package/v2Components/HtmlEditor/components/FullscreenModal/_fullscreenModal.scss +22 -0
- package/v2Components/HtmlEditor/components/InAppPreviewPane/DeviceFrame.js +4 -7
- package/v2Components/HtmlEditor/components/InAppPreviewPane/__tests__/DeviceFrame.test.js +35 -45
- package/v2Components/HtmlEditor/components/InAppPreviewPane/_inAppPreviewPane.scss +1 -3
- package/v2Components/HtmlEditor/components/InAppPreviewPane/constants.js +33 -33
- package/v2Components/HtmlEditor/components/InAppPreviewPane/index.js +7 -6
- package/v2Components/HtmlEditor/components/PreviewPane/_previewPane.scss +3 -6
- package/v2Components/HtmlEditor/components/PreviewPane/index.js +10 -11
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/__tests__/index.test.js +70 -72
- package/v2Components/HtmlEditor/components/ValidationErrorDisplay/index.js +49 -31
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +254 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +362 -0
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +51 -0
- package/v2Components/HtmlEditor/constants.js +29 -20
- package/v2Components/HtmlEditor/hooks/__tests__/useInAppContent.test.js +373 -16
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +5 -2
- package/v2Components/HtmlEditor/hooks/useInAppContent.js +88 -146
- package/v2Components/HtmlEditor/index.js +1 -1
- package/v2Components/HtmlEditor/messages.js +95 -85
- package/v2Components/HtmlEditor/utils/liquidTemplateSupport.js +99 -101
- package/v2Components/HtmlEditor/utils/properSyntaxHighlighting.js +23 -25
- package/v2Components/HtmlEditor/utils/validationAdapter.js +34 -41
- package/v2Components/MobilePushPreviewV2/index.js +32 -7
- package/v2Components/TemplatePreview/_templatePreview.scss +44 -24
- package/v2Components/TemplatePreview/index.js +47 -32
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +31 -25
- package/v2Containers/App/constants.js +0 -5
- package/v2Containers/BeeEditor/index.js +82 -80
- package/v2Containers/BeePopupEditor/constants.js +10 -0
- package/v2Containers/BeePopupEditor/index.js +193 -0
- package/v2Containers/BeePopupEditor/tests/index.test.js +627 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +148 -120
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +9 -3
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -2
- package/v2Containers/CreativesContainer/constants.js +1 -2
- package/v2Containers/CreativesContainer/index.js +173 -193
- package/v2Containers/CreativesContainer/messages.js +4 -4
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +38 -50
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +36 -0
- package/v2Containers/Email/actions.js +7 -0
- package/v2Containers/Email/constants.js +5 -1
- package/v2Containers/Email/index.js +13 -0
- package/v2Containers/Email/messages.js +32 -0
- package/v2Containers/Email/reducer.js +12 -1
- package/v2Containers/Email/sagas.js +41 -6
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +2 -0
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +1046 -0
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +193 -7
- package/v2Containers/EmailWrapper/components/HTMLEditorTesting.js +40 -74
- package/v2Containers/EmailWrapper/components/__tests__/HTMLEditorTesting.test.js +2 -67
- package/v2Containers/EmailWrapper/constants.js +2 -0
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +436 -67
- package/v2Containers/EmailWrapper/index.js +99 -23
- package/v2Containers/EmailWrapper/messages.js +61 -1
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +111 -77
- package/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +376 -0
- package/v2Containers/InApp/__tests__/sagas.test.js +363 -0
- package/v2Containers/InApp/actions.js +7 -0
- package/v2Containers/InApp/constants.js +20 -4
- package/v2Containers/InApp/index.js +801 -357
- package/v2Containers/InApp/index.scss +4 -3
- package/v2Containers/InApp/messages.js +7 -3
- package/v2Containers/InApp/reducer.js +21 -3
- package/v2Containers/InApp/sagas.js +29 -9
- package/v2Containers/InApp/selectors.js +25 -5
- package/v2Containers/InApp/tests/index.test.js +154 -50
- package/v2Containers/InApp/tests/reducer.test.js +34 -0
- package/v2Containers/InApp/tests/sagas.test.js +61 -9
- package/v2Containers/InApp/tests/selectors.test.js +612 -0
- package/v2Containers/InAppWrapper/components/InAppWrapperView.js +162 -0
- package/v2Containers/InAppWrapper/components/__tests__/InAppWrapperView.test.js +267 -0
- package/v2Containers/InAppWrapper/components/inAppWrapperView.scss +9 -0
- package/v2Containers/InAppWrapper/constants.js +16 -0
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +473 -0
- package/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +198 -0
- package/v2Containers/InAppWrapper/index.js +148 -0
- package/v2Containers/InAppWrapper/messages.js +49 -0
- package/v2Containers/InappAdvance/index.js +1099 -0
- package/v2Containers/InappAdvance/index.scss +10 -0
- package/v2Containers/InappAdvance/tests/index.test.js +448 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -25
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -18
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -46
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -8
- package/v2Containers/TagList/index.js +67 -1
- package/v2Containers/Templates/ChannelTypeIllustration.js +1 -13
- package/v2Containers/Templates/_templates.scss +56 -200
- package/v2Containers/Templates/actions.js +1 -2
- package/v2Containers/Templates/constants.js +0 -1
- package/v2Containers/Templates/index.js +124 -277
- package/v2Containers/Templates/messages.js +4 -24
- package/v2Containers/Templates/reducer.js +0 -2
- package/v2Containers/Templates/tests/index.test.js +0 -10
- package/v2Containers/TemplatesV2/index.js +2 -3
- package/v2Containers/TemplatesV2/messages.js +0 -4
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -132
- package/v2Components/CapImageUrlUpload/constants.js +0 -19
- package/v2Components/CapImageUrlUpload/index.js +0 -455
- package/v2Components/CapImageUrlUpload/index.scss +0 -35
- package/v2Components/CapImageUrlUpload/messages.js +0 -47
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +0 -214
- package/v2Containers/WebPush/Create/components/ButtonForm.js +0 -175
- package/v2Containers/WebPush/Create/components/ButtonItem.js +0 -101
- package/v2Containers/WebPush/Create/components/ButtonList.js +0 -144
- package/v2Containers/WebPush/Create/components/_buttons.scss +0 -246
- package/v2Containers/WebPush/Create/components/tests/ButtonForm.test.js +0 -554
- package/v2Containers/WebPush/Create/components/tests/ButtonItem.test.js +0 -607
- package/v2Containers/WebPush/Create/components/tests/ButtonList.test.js +0 -633
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonForm.test.js.snap +0 -666
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonItem.test.js.snap +0 -74
- package/v2Containers/WebPush/Create/components/tests/__snapshots__/ButtonList.test.js.snap +0 -80
- package/v2Containers/WebPush/Create/index.js +0 -1755
- package/v2Containers/WebPush/Create/index.scss +0 -123
- package/v2Containers/WebPush/Create/messages.js +0 -199
- package/v2Containers/WebPush/Create/preview/DevicePreviewContent.js +0 -241
- package/v2Containers/WebPush/Create/preview/NotificationContainer.js +0 -290
- package/v2Containers/WebPush/Create/preview/PreviewContent.js +0 -81
- package/v2Containers/WebPush/Create/preview/PreviewControls.js +0 -240
- package/v2Containers/WebPush/Create/preview/PreviewDisclaimer.js +0 -23
- package/v2Containers/WebPush/Create/preview/WebPushPreview.js +0 -144
- package/v2Containers/WebPush/Create/preview/assets/Light.svg +0 -53
- package/v2Containers/WebPush/Create/preview/assets/Top.svg +0 -5
- package/v2Containers/WebPush/Create/preview/assets/chrome-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/edge-icon.png +0 -0
- package/v2Containers/WebPush/Create/preview/assets/firefox-icon.svg +0 -106
- package/v2Containers/WebPush/Create/preview/assets/iOS.svg +0 -26
- package/v2Containers/WebPush/Create/preview/assets/opera-icon.svg +0 -18
- package/v2Containers/WebPush/Create/preview/assets/safari-icon.svg +0 -29
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileChromeHeader.js +0 -44
- package/v2Containers/WebPush/Create/preview/components/AndroidMobileExpanded.js +0 -110
- package/v2Containers/WebPush/Create/preview/components/IOSHeader.js +0 -45
- package/v2Containers/WebPush/Create/preview/components/NotificationExpandedContent.js +0 -72
- package/v2Containers/WebPush/Create/preview/components/NotificationHeader.js +0 -55
- package/v2Containers/WebPush/Create/preview/components/WindowsChromeExpanded.js +0 -70
- package/v2Containers/WebPush/Create/preview/components/tests/AndroidMobileExpanded.test.js +0 -512
- package/v2Containers/WebPush/Create/preview/components/tests/__snapshots__/AndroidMobileExpanded.test.js.snap +0 -77
- package/v2Containers/WebPush/Create/preview/config/notificationMappings.js +0 -527
- package/v2Containers/WebPush/Create/preview/constants.js +0 -162
- package/v2Containers/WebPush/Create/preview/notification-container.scss +0 -104
- package/v2Containers/WebPush/Create/preview/preview.scss +0 -409
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-chrome.scss +0 -300
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-edge.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-firefox.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-mobile-opera.scss +0 -12
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-chrome.scss +0 -303
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-edge.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-firefox.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_android-tablet-opera.scss +0 -11
- package/v2Containers/WebPush/Create/preview/styles/_base.scss +0 -188
- package/v2Containers/WebPush/Create/preview/styles/_ios.scss +0 -106
- package/v2Containers/WebPush/Create/preview/styles/_ipados.scss +0 -107
- package/v2Containers/WebPush/Create/preview/styles/_macos-chrome.scss +0 -75
- package/v2Containers/WebPush/Create/preview/styles/_windows-chrome.scss +0 -174
- package/v2Containers/WebPush/Create/preview/tests/DevicePreviewContent.test.js +0 -909
- package/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +0 -1077
- package/v2Containers/WebPush/Create/preview/tests/PreviewControls.test.js +0 -723
- package/v2Containers/WebPush/Create/preview/tests/WebPushPreview.test.js +0 -943
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/DevicePreviewContent.test.js.snap +0 -128
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/NotificationContainer.test.js.snap +0 -121
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/PreviewControls.test.js.snap +0 -144
- package/v2Containers/WebPush/Create/preview/tests/__snapshots__/WebPushPreview.test.js.snap +0 -127
- package/v2Containers/WebPush/Create/utils/urlValidation.js +0 -116
- package/v2Containers/WebPush/Create/utils/urlValidation.test.js +0 -449
- package/v2Containers/WebPush/actions.js +0 -60
- package/v2Containers/WebPush/constants.js +0 -108
- package/v2Containers/WebPush/index.js +0 -2
- package/v2Containers/WebPush/reducer.js +0 -104
- package/v2Containers/WebPush/sagas.js +0 -119
- package/v2Containers/WebPush/selectors.js +0 -65
- package/v2Containers/WebPush/tests/reducer.test.js +0 -863
- package/v2Containers/WebPush/tests/sagas.test.js +0 -566
- package/v2Containers/WebPush/tests/selectors.test.js +0 -960
|
@@ -1,607 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mountWithIntl, shallowWithIntl } from '../../../../../helpers/intl-enzym-test-helpers';
|
|
3
|
-
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
4
|
-
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
5
|
-
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
6
|
-
import ButtonItem from '../ButtonItem';
|
|
7
|
-
|
|
8
|
-
describe('ButtonItem', () => {
|
|
9
|
-
const mockButton = {
|
|
10
|
-
text: 'Click Me',
|
|
11
|
-
url: 'https://example.com',
|
|
12
|
-
type: 'primary',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const mockOnEdit = jest.fn();
|
|
16
|
-
const mockOnDelete = jest.fn();
|
|
17
|
-
const mockOnDragStart = jest.fn();
|
|
18
|
-
const mockOnDragOver = jest.fn();
|
|
19
|
-
const mockOnDrop = jest.fn();
|
|
20
|
-
const mockOnDragEnd = jest.fn();
|
|
21
|
-
|
|
22
|
-
const defaultProps = {
|
|
23
|
-
button: mockButton,
|
|
24
|
-
index: 0,
|
|
25
|
-
onEdit: mockOnEdit,
|
|
26
|
-
onDelete: mockOnDelete,
|
|
27
|
-
onDragStart: mockOnDragStart,
|
|
28
|
-
onDragOver: mockOnDragOver,
|
|
29
|
-
onDrop: mockOnDrop,
|
|
30
|
-
onDragEnd: mockOnDragEnd,
|
|
31
|
-
disabled: false,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
jest.clearAllMocks();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('Rendering', () => {
|
|
39
|
-
it('should render correctly with default props', () => {
|
|
40
|
-
const wrapper = shallowWithIntl(<ButtonItem {...defaultProps} />);
|
|
41
|
-
expect(wrapper).toMatchSnapshot();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should render button text', () => {
|
|
45
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
46
|
-
const textElement = wrapper.find('.button-item-text');
|
|
47
|
-
expect(textElement.exists()).toBe(true);
|
|
48
|
-
expect(textElement.text()).toBe(mockButton.text);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should render button URL', () => {
|
|
52
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
53
|
-
const urlElement = wrapper.find('.button-item-url');
|
|
54
|
-
expect(urlElement.exists()).toBe(true);
|
|
55
|
-
expect(urlElement.text()).toBe(mockButton.url);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should render drag icon', () => {
|
|
59
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
60
|
-
const dragIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'drag');
|
|
61
|
-
expect(dragIcon.exists()).toBe(true);
|
|
62
|
-
expect(dragIcon.prop('className')).toBe('drag-icon');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should render link icon', () => {
|
|
66
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
67
|
-
const linkIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'link').first();
|
|
68
|
-
expect(linkIcon.exists()).toBe(true);
|
|
69
|
-
expect(linkIcon.prop('className')).toBe('link-icon');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should render edit icon', () => {
|
|
73
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
74
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit');
|
|
75
|
-
expect(editIcon.exists()).toBe(true);
|
|
76
|
-
expect(editIcon.prop('className')).toBe('action-icon');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should render delete icon', () => {
|
|
80
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
81
|
-
const deleteIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'delete');
|
|
82
|
-
expect(deleteIcon.exists()).toBe(true);
|
|
83
|
-
expect(deleteIcon.prop('className')).toBe('action-icon delete-icon');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should render CapRow with correct props', () => {
|
|
87
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
88
|
-
const capRow = wrapper.find(CapRow).first();
|
|
89
|
-
expect(capRow.exists()).toBe(true);
|
|
90
|
-
expect(capRow.prop('align')).toBe('middle');
|
|
91
|
-
expect(capRow.prop('className')).toBe('button-item-content');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should render CapColumns with correct spans', () => {
|
|
95
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
96
|
-
const columns = wrapper.find(CapColumn);
|
|
97
|
-
|
|
98
|
-
expect(columns.at(0).prop('span')).toBe(1);
|
|
99
|
-
expect(columns.at(0).prop('className')).toBe('button-item-drag-handle');
|
|
100
|
-
|
|
101
|
-
expect(columns.at(1).prop('span')).toBe(1);
|
|
102
|
-
expect(columns.at(1).prop('className')).toBe('button-item-icon');
|
|
103
|
-
|
|
104
|
-
expect(columns.at(2).prop('span')).toBe(14);
|
|
105
|
-
expect(columns.at(2).prop('className')).toBe('button-item-info');
|
|
106
|
-
|
|
107
|
-
expect(columns.at(3).prop('span')).toBe(8);
|
|
108
|
-
expect(columns.at(3).prop('className')).toBe('button-item-actions');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should render with different button data', () => {
|
|
112
|
-
const customButton = {
|
|
113
|
-
text: 'Custom Button',
|
|
114
|
-
url: 'https://custom.com',
|
|
115
|
-
type: 'secondary',
|
|
116
|
-
};
|
|
117
|
-
const wrapper = mountWithIntl(
|
|
118
|
-
<ButtonItem {...defaultProps} button={customButton} />
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
expect(wrapper.find('.button-item-text').text()).toBe(customButton.text);
|
|
122
|
-
expect(wrapper.find('.button-item-url').text()).toBe(customButton.url);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('Disabled State', () => {
|
|
127
|
-
it('should add disabled class when disabled is true', () => {
|
|
128
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
129
|
-
const container = wrapper.find('.webpush-button-item');
|
|
130
|
-
expect(container.hasClass('disabled')).toBe(true);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should not add disabled class when disabled is false', () => {
|
|
134
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={false} />);
|
|
135
|
-
const container = wrapper.find('.webpush-button-item');
|
|
136
|
-
expect(container.hasClass('disabled')).toBe(false);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should not add disabled class when disabled prop is not provided (defaults to false)', () => {
|
|
140
|
-
const { disabled, ...propsWithoutDisabled } = defaultProps;
|
|
141
|
-
const wrapper = mountWithIntl(<ButtonItem {...propsWithoutDisabled} />);
|
|
142
|
-
const container = wrapper.find('.webpush-button-item');
|
|
143
|
-
expect(container.hasClass('disabled')).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('should set draggable to false when disabled is true', () => {
|
|
147
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
148
|
-
const container = wrapper.find('.webpush-button-item');
|
|
149
|
-
expect(container.prop('draggable')).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('should set draggable to true when disabled is false', () => {
|
|
153
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={false} />);
|
|
154
|
-
const container = wrapper.find('.webpush-button-item');
|
|
155
|
-
expect(container.prop('draggable')).toBe(true);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should set draggable to true when disabled prop is not provided', () => {
|
|
159
|
-
const { disabled, ...propsWithoutDisabled } = defaultProps;
|
|
160
|
-
const wrapper = mountWithIntl(<ButtonItem {...propsWithoutDisabled} />);
|
|
161
|
-
const container = wrapper.find('.webpush-button-item');
|
|
162
|
-
expect(container.prop('draggable')).toBe(true);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('Drag and Drop - handleDragStart', () => {
|
|
167
|
-
it('should call onDragStart with correct index when drag starts', () => {
|
|
168
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={2} />);
|
|
169
|
-
const container = wrapper.find('.webpush-button-item');
|
|
170
|
-
|
|
171
|
-
const mockEvent = {
|
|
172
|
-
dataTransfer: {
|
|
173
|
-
effectAllowed: '',
|
|
174
|
-
setData: jest.fn(),
|
|
175
|
-
},
|
|
176
|
-
currentTarget: container.instance(),
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
container.simulate('dragStart', mockEvent);
|
|
180
|
-
|
|
181
|
-
expect(mockOnDragStart).toHaveBeenCalledWith(2);
|
|
182
|
-
expect(mockOnDragStart).toHaveBeenCalledTimes(1);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should set dataTransfer.effectAllowed to "move" on drag start', () => {
|
|
186
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
187
|
-
const container = wrapper.find('.webpush-button-item');
|
|
188
|
-
|
|
189
|
-
const mockEvent = {
|
|
190
|
-
dataTransfer: {
|
|
191
|
-
effectAllowed: '',
|
|
192
|
-
setData: jest.fn(),
|
|
193
|
-
},
|
|
194
|
-
currentTarget: container.instance(),
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
container.simulate('dragStart', mockEvent);
|
|
198
|
-
|
|
199
|
-
expect(mockEvent.dataTransfer.effectAllowed).toBe('move');
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('should call setData with correct parameters on drag start', () => {
|
|
203
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
204
|
-
const container = wrapper.find('.webpush-button-item');
|
|
205
|
-
|
|
206
|
-
const mockEvent = {
|
|
207
|
-
dataTransfer: {
|
|
208
|
-
effectAllowed: '',
|
|
209
|
-
setData: jest.fn(),
|
|
210
|
-
},
|
|
211
|
-
currentTarget: container.instance(),
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
container.simulate('dragStart', mockEvent);
|
|
215
|
-
|
|
216
|
-
expect(mockEvent.dataTransfer.setData).toHaveBeenCalledWith('text/html', mockEvent.currentTarget);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should not call onDragStart when disabled is true', () => {
|
|
220
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
221
|
-
const container = wrapper.find('.webpush-button-item');
|
|
222
|
-
|
|
223
|
-
const mockEvent = {
|
|
224
|
-
dataTransfer: {
|
|
225
|
-
effectAllowed: '',
|
|
226
|
-
setData: jest.fn(),
|
|
227
|
-
},
|
|
228
|
-
currentTarget: container.instance(),
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
container.simulate('dragStart', mockEvent);
|
|
232
|
-
|
|
233
|
-
expect(mockOnDragStart).not.toHaveBeenCalled();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('should not modify dataTransfer when disabled is true', () => {
|
|
237
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
238
|
-
const container = wrapper.find('.webpush-button-item');
|
|
239
|
-
|
|
240
|
-
const mockEvent = {
|
|
241
|
-
dataTransfer: {
|
|
242
|
-
effectAllowed: '',
|
|
243
|
-
setData: jest.fn(),
|
|
244
|
-
},
|
|
245
|
-
currentTarget: container.instance(),
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const originalEffectAllowed = mockEvent.dataTransfer.effectAllowed;
|
|
249
|
-
container.simulate('dragStart', mockEvent);
|
|
250
|
-
|
|
251
|
-
expect(mockEvent.dataTransfer.effectAllowed).toBe(originalEffectAllowed);
|
|
252
|
-
expect(mockEvent.dataTransfer.setData).not.toHaveBeenCalled();
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
describe('Drag and Drop - handleDragOver', () => {
|
|
257
|
-
it('should call onDragOver with correct index when dragging over', () => {
|
|
258
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={3} />);
|
|
259
|
-
const container = wrapper.find('.webpush-button-item');
|
|
260
|
-
|
|
261
|
-
const mockEvent = {
|
|
262
|
-
preventDefault: jest.fn(),
|
|
263
|
-
dataTransfer: {
|
|
264
|
-
dropEffect: '',
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
container.simulate('dragOver', mockEvent);
|
|
269
|
-
|
|
270
|
-
expect(mockOnDragOver).toHaveBeenCalledWith(3);
|
|
271
|
-
expect(mockOnDragOver).toHaveBeenCalledTimes(1);
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it('should call preventDefault on drag over', () => {
|
|
275
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
276
|
-
const container = wrapper.find('.webpush-button-item');
|
|
277
|
-
|
|
278
|
-
const mockEvent = {
|
|
279
|
-
preventDefault: jest.fn(),
|
|
280
|
-
dataTransfer: {
|
|
281
|
-
dropEffect: '',
|
|
282
|
-
},
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
container.simulate('dragOver', mockEvent);
|
|
286
|
-
|
|
287
|
-
expect(mockEvent.preventDefault).toHaveBeenCalledTimes(1);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('should set dataTransfer.dropEffect to "move" on drag over', () => {
|
|
291
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
292
|
-
const container = wrapper.find('.webpush-button-item');
|
|
293
|
-
|
|
294
|
-
const mockEvent = {
|
|
295
|
-
preventDefault: jest.fn(),
|
|
296
|
-
dataTransfer: {
|
|
297
|
-
dropEffect: '',
|
|
298
|
-
},
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
container.simulate('dragOver', mockEvent);
|
|
302
|
-
|
|
303
|
-
expect(mockEvent.dataTransfer.dropEffect).toBe('move');
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('should not call onDragOver when disabled is true', () => {
|
|
307
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
308
|
-
const container = wrapper.find('.webpush-button-item');
|
|
309
|
-
|
|
310
|
-
const mockEvent = {
|
|
311
|
-
preventDefault: jest.fn(),
|
|
312
|
-
dataTransfer: {
|
|
313
|
-
dropEffect: '',
|
|
314
|
-
},
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
container.simulate('dragOver', mockEvent);
|
|
318
|
-
|
|
319
|
-
expect(mockOnDragOver).not.toHaveBeenCalled();
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('should not call preventDefault when disabled is true', () => {
|
|
323
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
324
|
-
const container = wrapper.find('.webpush-button-item');
|
|
325
|
-
|
|
326
|
-
const mockEvent = {
|
|
327
|
-
preventDefault: jest.fn(),
|
|
328
|
-
dataTransfer: {
|
|
329
|
-
dropEffect: '',
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
container.simulate('dragOver', mockEvent);
|
|
334
|
-
|
|
335
|
-
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
describe('Drag and Drop - handleDrop', () => {
|
|
340
|
-
it('should call onDrop with correct index when drop occurs', () => {
|
|
341
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={1} />);
|
|
342
|
-
const container = wrapper.find('.webpush-button-item');
|
|
343
|
-
|
|
344
|
-
const mockEvent = {
|
|
345
|
-
preventDefault: jest.fn(),
|
|
346
|
-
stopPropagation: jest.fn(),
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
container.simulate('drop', mockEvent);
|
|
350
|
-
|
|
351
|
-
expect(mockOnDrop).toHaveBeenCalledWith(1);
|
|
352
|
-
expect(mockOnDrop).toHaveBeenCalledTimes(1);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it('should call preventDefault on drop', () => {
|
|
356
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
357
|
-
const container = wrapper.find('.webpush-button-item');
|
|
358
|
-
|
|
359
|
-
const mockEvent = {
|
|
360
|
-
preventDefault: jest.fn(),
|
|
361
|
-
stopPropagation: jest.fn(),
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
container.simulate('drop', mockEvent);
|
|
365
|
-
|
|
366
|
-
expect(mockEvent.preventDefault).toHaveBeenCalledTimes(1);
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
it('should call stopPropagation on drop', () => {
|
|
370
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
371
|
-
const container = wrapper.find('.webpush-button-item');
|
|
372
|
-
|
|
373
|
-
const mockEvent = {
|
|
374
|
-
preventDefault: jest.fn(),
|
|
375
|
-
stopPropagation: jest.fn(),
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
container.simulate('drop', mockEvent);
|
|
379
|
-
|
|
380
|
-
expect(mockEvent.stopPropagation).toHaveBeenCalledTimes(1);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it('should not call onDrop when disabled is true', () => {
|
|
384
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
385
|
-
const container = wrapper.find('.webpush-button-item');
|
|
386
|
-
|
|
387
|
-
const mockEvent = {
|
|
388
|
-
preventDefault: jest.fn(),
|
|
389
|
-
stopPropagation: jest.fn(),
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
container.simulate('drop', mockEvent);
|
|
393
|
-
|
|
394
|
-
expect(mockOnDrop).not.toHaveBeenCalled();
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('should not call preventDefault or stopPropagation when disabled is true', () => {
|
|
398
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
399
|
-
const container = wrapper.find('.webpush-button-item');
|
|
400
|
-
|
|
401
|
-
const mockEvent = {
|
|
402
|
-
preventDefault: jest.fn(),
|
|
403
|
-
stopPropagation: jest.fn(),
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
container.simulate('drop', mockEvent);
|
|
407
|
-
|
|
408
|
-
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
|
409
|
-
expect(mockEvent.stopPropagation).not.toHaveBeenCalled();
|
|
410
|
-
});
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
describe('Drag and Drop - onDragEnd', () => {
|
|
414
|
-
it('should call onDragEnd when drag ends', () => {
|
|
415
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
416
|
-
const container = wrapper.find('.webpush-button-item');
|
|
417
|
-
|
|
418
|
-
container.simulate('dragEnd');
|
|
419
|
-
|
|
420
|
-
expect(mockOnDragEnd).toHaveBeenCalledTimes(1);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it('should call onDragEnd even when disabled is true', () => {
|
|
424
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
425
|
-
const container = wrapper.find('.webpush-button-item');
|
|
426
|
-
|
|
427
|
-
container.simulate('dragEnd');
|
|
428
|
-
|
|
429
|
-
expect(mockOnDragEnd).toHaveBeenCalledTimes(1);
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
describe('Edit Functionality', () => {
|
|
434
|
-
it('should call onEdit with correct index when edit icon is clicked', () => {
|
|
435
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={2} />);
|
|
436
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit').first();
|
|
437
|
-
|
|
438
|
-
editIcon.prop('onClick')();
|
|
439
|
-
|
|
440
|
-
expect(mockOnEdit).toHaveBeenCalledWith(2);
|
|
441
|
-
expect(mockOnEdit).toHaveBeenCalledTimes(1);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
it('should not call onEdit when disabled is true', () => {
|
|
445
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
446
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit').first();
|
|
447
|
-
|
|
448
|
-
editIcon.prop('onClick')();
|
|
449
|
-
|
|
450
|
-
expect(mockOnEdit).not.toHaveBeenCalled();
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it('should call onEdit when disabled is false', () => {
|
|
454
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={false} />);
|
|
455
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit').first();
|
|
456
|
-
|
|
457
|
-
editIcon.prop('onClick')();
|
|
458
|
-
|
|
459
|
-
expect(mockOnEdit).toHaveBeenCalledWith(0);
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
describe('Delete Functionality', () => {
|
|
464
|
-
it('should call onDelete with correct index when delete icon is clicked', () => {
|
|
465
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={1} />);
|
|
466
|
-
const deleteIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'delete').first();
|
|
467
|
-
|
|
468
|
-
deleteIcon.prop('onClick')();
|
|
469
|
-
|
|
470
|
-
expect(mockOnDelete).toHaveBeenCalledWith(1);
|
|
471
|
-
expect(mockOnDelete).toHaveBeenCalledTimes(1);
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
it('should not call onDelete when disabled is true', () => {
|
|
475
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
476
|
-
const deleteIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'delete').first();
|
|
477
|
-
|
|
478
|
-
deleteIcon.prop('onClick')();
|
|
479
|
-
|
|
480
|
-
expect(mockOnDelete).not.toHaveBeenCalled();
|
|
481
|
-
});
|
|
482
|
-
|
|
483
|
-
it('should call onDelete when disabled is false', () => {
|
|
484
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={false} />);
|
|
485
|
-
const deleteIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'delete').first();
|
|
486
|
-
|
|
487
|
-
deleteIcon.prop('onClick')();
|
|
488
|
-
|
|
489
|
-
expect(mockOnDelete).toHaveBeenCalledWith(0);
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
describe('Props Validation', () => {
|
|
494
|
-
it('should handle different index values', () => {
|
|
495
|
-
const indices = [0, 1, 5, 10];
|
|
496
|
-
indices.forEach((index) => {
|
|
497
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} index={index} />);
|
|
498
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit').first();
|
|
499
|
-
editIcon.prop('onClick')();
|
|
500
|
-
expect(mockOnEdit).toHaveBeenCalledWith(index);
|
|
501
|
-
mockOnEdit.mockClear();
|
|
502
|
-
});
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
it('should handle empty button text', () => {
|
|
506
|
-
const emptyButton = {
|
|
507
|
-
text: '',
|
|
508
|
-
url: 'https://example.com',
|
|
509
|
-
type: 'primary',
|
|
510
|
-
};
|
|
511
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} button={emptyButton} />);
|
|
512
|
-
const textElement = wrapper.find('.button-item-text');
|
|
513
|
-
expect(textElement.text()).toBe('');
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it('should handle empty button URL', () => {
|
|
517
|
-
const emptyUrlButton = {
|
|
518
|
-
text: 'Button Text',
|
|
519
|
-
url: '',
|
|
520
|
-
type: 'primary',
|
|
521
|
-
};
|
|
522
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} button={emptyUrlButton} />);
|
|
523
|
-
const urlElement = wrapper.find('.button-item-url');
|
|
524
|
-
expect(urlElement.text()).toBe('');
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
it('should handle long button text', () => {
|
|
528
|
-
const longTextButton = {
|
|
529
|
-
text: 'A'.repeat(100),
|
|
530
|
-
url: 'https://example.com',
|
|
531
|
-
type: 'primary',
|
|
532
|
-
};
|
|
533
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} button={longTextButton} />);
|
|
534
|
-
const textElement = wrapper.find('.button-item-text');
|
|
535
|
-
expect(textElement.text()).toBe(longTextButton.text);
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
it('should handle long button URL', () => {
|
|
539
|
-
const longUrlButton = {
|
|
540
|
-
text: 'Button',
|
|
541
|
-
url: 'https://example.com/' + 'a'.repeat(200),
|
|
542
|
-
type: 'primary',
|
|
543
|
-
};
|
|
544
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} button={longUrlButton} />);
|
|
545
|
-
const urlElement = wrapper.find('.button-item-url');
|
|
546
|
-
expect(urlElement.text()).toBe(longUrlButton.url);
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
describe('Edge Cases', () => {
|
|
551
|
-
it('should handle all drag events when disabled prevents all interactions', () => {
|
|
552
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} disabled={true} />);
|
|
553
|
-
const container = wrapper.find('.webpush-button-item');
|
|
554
|
-
|
|
555
|
-
const dragStartEvent = {
|
|
556
|
-
dataTransfer: { effectAllowed: '', setData: jest.fn() },
|
|
557
|
-
currentTarget: container.instance(),
|
|
558
|
-
};
|
|
559
|
-
const dragOverEvent = {
|
|
560
|
-
preventDefault: jest.fn(),
|
|
561
|
-
dataTransfer: { dropEffect: '' },
|
|
562
|
-
};
|
|
563
|
-
const dropEvent = {
|
|
564
|
-
preventDefault: jest.fn(),
|
|
565
|
-
stopPropagation: jest.fn(),
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
container.simulate('dragStart', dragStartEvent);
|
|
569
|
-
container.simulate('dragOver', dragOverEvent);
|
|
570
|
-
container.simulate('drop', dropEvent);
|
|
571
|
-
|
|
572
|
-
expect(mockOnDragStart).not.toHaveBeenCalled();
|
|
573
|
-
expect(mockOnDragOver).not.toHaveBeenCalled();
|
|
574
|
-
expect(mockOnDrop).not.toHaveBeenCalled();
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
it('should handle rapid successive drag operations', () => {
|
|
578
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
579
|
-
const container = wrapper.find('.webpush-button-item');
|
|
580
|
-
|
|
581
|
-
const mockDragStartEvent = {
|
|
582
|
-
dataTransfer: { effectAllowed: '', setData: jest.fn() },
|
|
583
|
-
currentTarget: container.instance(),
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
// Simulate rapid drag starts
|
|
587
|
-
container.simulate('dragStart', mockDragStartEvent);
|
|
588
|
-
container.simulate('dragStart', mockDragStartEvent);
|
|
589
|
-
container.simulate('dragStart', mockDragStartEvent);
|
|
590
|
-
|
|
591
|
-
expect(mockOnDragStart).toHaveBeenCalledTimes(3);
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
it('should handle edit and delete clicks when not disabled', () => {
|
|
595
|
-
const wrapper = mountWithIntl(<ButtonItem {...defaultProps} />);
|
|
596
|
-
const editIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'edit').first();
|
|
597
|
-
const deleteIcon = wrapper.find(CapIcon).findWhere((node) => node.prop('type') === 'delete').first();
|
|
598
|
-
|
|
599
|
-
editIcon.prop('onClick')();
|
|
600
|
-
deleteIcon.prop('onClick')();
|
|
601
|
-
|
|
602
|
-
expect(mockOnEdit).toHaveBeenCalledTimes(1);
|
|
603
|
-
expect(mockOnDelete).toHaveBeenCalledTimes(1);
|
|
604
|
-
});
|
|
605
|
-
});
|
|
606
|
-
});
|
|
607
|
-
|