@pushwoosh/dumb-components 2.9.12 → 2.9.14
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/Switch/styles.js +1 -1
- package/package.json +4 -6
- package/Banner/__tests__/Banner.test.d.ts +0 -1
- package/Banner/__tests__/Banner.test.js +0 -57
- package/Button/__tests__/Button.test.d.ts +0 -1
- package/Button/__tests__/Button.test.js +0 -27
- package/Calendar/__tests__/CalendarMonthSlider.test.d.ts +0 -1
- package/Calendar/__tests__/CalendarMonthSlider.test.js +0 -85
- package/Calendar/__tests__/CellBox.test.d.ts +0 -1
- package/Calendar/__tests__/CellBox.test.js +0 -34
- package/Calendar/__tests__/helpers.test.d.ts +0 -1
- package/Calendar/__tests__/helpers.test.js +0 -143
- package/CardMetric/__tests__/CardMetric.test.d.ts +0 -1
- package/CardMetric/__tests__/CardMetric.test.js +0 -31
- package/Chip/__tests__/Chip.test.d.ts +0 -1
- package/Chip/__tests__/Chip.test.js +0 -101
- package/DateTimePicker/__tests__/YearView.test.d.ts +0 -1
- package/DateTimePicker/__tests__/YearView.test.js +0 -15
- package/DropdownMenu/__tests__/DropdownMenuItem.test.d.ts +0 -1
- package/DropdownMenu/__tests__/DropdownMenuItem.test.js +0 -109
- package/EditableField/__tests__/EditableField.test.d.ts +0 -1
- package/EditableField/__tests__/EditableField.test.js +0 -19
- package/EmailTemplatePreview/__tests__/clickMap.test.d.ts +0 -1
- package/EmailTemplatePreview/__tests__/clickMap.test.js +0 -168
- package/ExternalImagePreview/__tests__/ExternalImagePreview.test.d.ts +0 -1
- package/ExternalImagePreview/__tests__/ExternalImagePreview.test.js +0 -18
- package/InboxPreview/__tests__/helpers.test.d.ts +0 -1
- package/InboxPreview/__tests__/helpers.test.js +0 -201
- package/NativeRichMediaPreview/__tests__/NativeRichMediaPreview.test.d.ts +0 -1
- package/NativeRichMediaPreview/__tests__/NativeRichMediaPreview.test.js +0 -81
- package/PageHeader/__tests__/PageHeader.test.d.ts +0 -1
- package/PageHeader/__tests__/PageHeader.test.js +0 -37
- package/PushPreview/__tests__/PushPreview.test.d.ts +0 -1
- package/PushPreview/__tests__/PushPreview.test.js +0 -26
- package/PushStoriesPreview/__tests__/PushStoriesPreview.test.d.ts +0 -1
- package/PushStoriesPreview/__tests__/PushStoriesPreview.test.js +0 -234
- package/RadioCard/__tests__/RadioCard.test.d.ts +0 -1
- package/RadioCard/__tests__/RadioCard.test.js +0 -23
- package/RichmediaPreview/__tests__/RichmediaPreview.test.d.ts +0 -1
- package/RichmediaPreview/__tests__/RichmediaPreview.test.js +0 -21
- package/SandboxedHtmlFrame/__tests__/SandboxedHtmlFrame.test.d.ts +0 -1
- package/SandboxedHtmlFrame/__tests__/SandboxedHtmlFrame.test.js +0 -57
- package/Skeleton/__tests__/Skeleton.test.d.ts +0 -1
- package/Skeleton/__tests__/Skeleton.test.js +0 -101
- package/Spinner/__tests__/Spinner.test.d.ts +0 -1
- package/Spinner/__tests__/Spinner.test.js +0 -15
- package/Switch/__tests__/Switch.test.d.ts +0 -1
- package/Switch/__tests__/Switch.test.js +0 -44
- package/Tabs/__tests__/TabBar.test.d.ts +0 -1
- package/Tabs/__tests__/TabBar.test.js +0 -36
- package/Toast/__tests__/Toast.test.d.ts +0 -1
- package/Toast/__tests__/Toast.test.js +0 -20
- package/WhatsAppPreview/__tests__/WhatsAppAttachment.test.d.ts +0 -1
- package/WhatsAppPreview/__tests__/WhatsAppAttachment.test.js +0 -53
- package/WhatsAppPreview/__tests__/WhatsAppPreview.test.d.ts +0 -1
- package/WhatsAppPreview/__tests__/WhatsAppPreview.test.js +0 -55
- package/WhatsAppPreview/__tests__/attachment.test.d.ts +0 -1
- package/WhatsAppPreview/__tests__/attachment.test.js +0 -103
- package/WhatsAppPreview/__tests__/parseWhatsAppMarkup.test.d.ts +0 -1
- package/WhatsAppPreview/__tests__/parseWhatsAppMarkup.test.js +0 -59
- package/helpers/__tests__/barcodeUrl.test.d.ts +0 -1
- package/helpers/__tests__/barcodeUrl.test.js +0 -43
- package/helpers/__tests__/timezones.test.d.ts +0 -1
- package/helpers/__tests__/timezones.test.js +0 -188
- package/hooks/__tests__/useLayer.test.d.ts +0 -1
- package/hooks/__tests__/useLayer.test.js +0 -71
- package/polyglot/__tests__/filters.test.d.ts +0 -1
- package/polyglot/__tests__/filters.test.js +0 -152
- package/polyglot/__tests__/helpers.test.d.ts +0 -1
- package/polyglot/__tests__/helpers.test.js +0 -176
- package/polyglot/__tests__/parser.test.d.ts +0 -1
- package/polyglot/__tests__/parser.test.js +0 -108
- package/polyglot/__tests__/render.test.d.ts +0 -1
- package/polyglot/__tests__/render.test.js +0 -285
- package/shared/dropdownField/__tests__/useDropdownPosition.test.d.ts +0 -1
- package/shared/dropdownField/__tests__/useDropdownPosition.test.js +0 -60
- package/shared/dynamicContent/__tests__/token.test.d.ts +0 -1
- package/shared/dynamicContent/__tests__/token.test.js +0 -32
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { hasStoryButton, normalizeStoryDuration } from '../helpers';
|
|
4
|
-
import { PushStoriesPreview } from '../PushStoriesPreview';
|
|
5
|
-
const pages = [{
|
|
6
|
-
image: 'https://example.com/1.jpg',
|
|
7
|
-
title: 'Welcome',
|
|
8
|
-
subtitle: 'Swipe to explore',
|
|
9
|
-
buttonTitle: 'Get started',
|
|
10
|
-
link: 'app://one'
|
|
11
|
-
}, {
|
|
12
|
-
image: 'https://example.com/2.jpg',
|
|
13
|
-
title: 'Stay in the loop',
|
|
14
|
-
duration: 4
|
|
15
|
-
}, {
|
|
16
|
-
image: 'https://example.com/3.jpg',
|
|
17
|
-
title: 'You are all set',
|
|
18
|
-
buttonTitle: 'Open app',
|
|
19
|
-
link: 'app://three'
|
|
20
|
-
}];
|
|
21
|
-
const next = () => {
|
|
22
|
-
fireEvent.click(screen.getByLabelText('Next page'));
|
|
23
|
-
};
|
|
24
|
-
const progressFill = index => screen.getByTestId('push-stories-progress').children[index].firstElementChild;
|
|
25
|
-
describe('normalizeStoryDuration', () => {
|
|
26
|
-
it('plays a missing, zero, negative or non-finite duration for 5 seconds', () => {
|
|
27
|
-
expect(normalizeStoryDuration(undefined)).toBe(5);
|
|
28
|
-
expect(normalizeStoryDuration(0)).toBe(5);
|
|
29
|
-
expect(normalizeStoryDuration(-3)).toBe(5);
|
|
30
|
-
expect(normalizeStoryDuration(Number.NaN)).toBe(5);
|
|
31
|
-
expect(normalizeStoryDuration(Number.POSITIVE_INFINITY)).toBe(5);
|
|
32
|
-
});
|
|
33
|
-
it('keeps a valid duration and caps it at 30 seconds', () => {
|
|
34
|
-
expect(normalizeStoryDuration(1.5)).toBe(1.5);
|
|
35
|
-
expect(normalizeStoryDuration(45)).toBe(30);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe('hasStoryButton', () => {
|
|
39
|
-
it('needs both a title and a link with a scheme, as the SDK does', () => {
|
|
40
|
-
expect(hasStoryButton({
|
|
41
|
-
buttonTitle: 'Go',
|
|
42
|
-
link: 'app://x'
|
|
43
|
-
})).toBe(true);
|
|
44
|
-
expect(hasStoryButton({
|
|
45
|
-
buttonTitle: 'Go',
|
|
46
|
-
link: 'https://example.com'
|
|
47
|
-
})).toBe(true);
|
|
48
|
-
expect(hasStoryButton({
|
|
49
|
-
buttonTitle: 'Go',
|
|
50
|
-
link: 'example.com/promo'
|
|
51
|
-
})).toBe(false);
|
|
52
|
-
expect(hasStoryButton({
|
|
53
|
-
buttonTitle: 'Go'
|
|
54
|
-
})).toBe(false);
|
|
55
|
-
expect(hasStoryButton({
|
|
56
|
-
buttonTitle: ' ',
|
|
57
|
-
link: 'app://x'
|
|
58
|
-
})).toBe(false);
|
|
59
|
-
expect(hasStoryButton({
|
|
60
|
-
link: 'app://x'
|
|
61
|
-
})).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe('PushStoriesPreview', () => {
|
|
65
|
-
it('draws the empty state without pages', () => {
|
|
66
|
-
render(_jsx(PushStoriesPreview, {
|
|
67
|
-
pages: []
|
|
68
|
-
}));
|
|
69
|
-
expect(screen.getByText('Add a page to see the story preview')).toBeInTheDocument();
|
|
70
|
-
expect(screen.queryByTestId('push-stories-progress')).not.toBeInTheDocument();
|
|
71
|
-
});
|
|
72
|
-
it('draws one progress segment per page and the first page text', () => {
|
|
73
|
-
render(_jsx(PushStoriesPreview, {
|
|
74
|
-
pages: pages
|
|
75
|
-
}));
|
|
76
|
-
expect(screen.getByTestId('push-stories-progress').children).toHaveLength(3);
|
|
77
|
-
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
|
78
|
-
expect(screen.getByText('Swipe to explore')).toBeInTheDocument();
|
|
79
|
-
expect(screen.getByText('Get started')).toBeInTheDocument();
|
|
80
|
-
});
|
|
81
|
-
it('keeps one segment per page and one image on screen through clicks and page list changes', () => {
|
|
82
|
-
const {
|
|
83
|
-
container,
|
|
84
|
-
rerender
|
|
85
|
-
} = render(_jsx(PushStoriesPreview, {
|
|
86
|
-
pages: pages
|
|
87
|
-
}));
|
|
88
|
-
const expectShape = count => {
|
|
89
|
-
expect(screen.getByTestId('push-stories-progress').children).toHaveLength(count);
|
|
90
|
-
expect(container.querySelectorAll('img')).toHaveLength(1);
|
|
91
|
-
};
|
|
92
|
-
for (let click = 0; click < 7; click += 1) {
|
|
93
|
-
expectShape(3);
|
|
94
|
-
next();
|
|
95
|
-
}
|
|
96
|
-
rerender(_jsx(PushStoriesPreview, {
|
|
97
|
-
pages: [...pages, {
|
|
98
|
-
image: 'https://example.com/4.jpg',
|
|
99
|
-
title: 'Fourth'
|
|
100
|
-
}]
|
|
101
|
-
}));
|
|
102
|
-
expectShape(4);
|
|
103
|
-
rerender(_jsx(PushStoriesPreview, {
|
|
104
|
-
pages: pages.slice(0, 2)
|
|
105
|
-
}));
|
|
106
|
-
expectShape(2);
|
|
107
|
-
});
|
|
108
|
-
it('hides the button of a page without a link', () => {
|
|
109
|
-
render(_jsx(PushStoriesPreview, {
|
|
110
|
-
pages: [{
|
|
111
|
-
...pages[0],
|
|
112
|
-
link: ''
|
|
113
|
-
}]
|
|
114
|
-
}));
|
|
115
|
-
expect(screen.queryByText('Get started')).not.toBeInTheDocument();
|
|
116
|
-
});
|
|
117
|
-
it('shows the next page on every click and goes round after the last one', () => {
|
|
118
|
-
render(_jsx(PushStoriesPreview, {
|
|
119
|
-
pages: pages
|
|
120
|
-
}));
|
|
121
|
-
next();
|
|
122
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
123
|
-
expect(progressFill(0)).not.toBeNull();
|
|
124
|
-
next();
|
|
125
|
-
expect(screen.getByText('You are all set')).toBeInTheDocument();
|
|
126
|
-
next();
|
|
127
|
-
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
|
128
|
-
expect(progressFill(1)).toBeNull();
|
|
129
|
-
next();
|
|
130
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
131
|
-
});
|
|
132
|
-
it('has a single click target over the whole story', () => {
|
|
133
|
-
render(_jsx(PushStoriesPreview, {
|
|
134
|
-
pages: pages
|
|
135
|
-
}));
|
|
136
|
-
expect(screen.getAllByRole('button')).toHaveLength(1);
|
|
137
|
-
});
|
|
138
|
-
it('follows the activeIndex prop and reports clicks instead of moving itself', () => {
|
|
139
|
-
const onActiveIndexChange = jest.fn();
|
|
140
|
-
const {
|
|
141
|
-
rerender
|
|
142
|
-
} = render(_jsx(PushStoriesPreview, {
|
|
143
|
-
pages: pages,
|
|
144
|
-
activeIndex: 1,
|
|
145
|
-
onActiveIndexChange: onActiveIndexChange
|
|
146
|
-
}));
|
|
147
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
148
|
-
next();
|
|
149
|
-
expect(onActiveIndexChange).toHaveBeenCalledWith(2);
|
|
150
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
151
|
-
rerender(_jsx(PushStoriesPreview, {
|
|
152
|
-
pages: pages,
|
|
153
|
-
activeIndex: 2,
|
|
154
|
-
onActiveIndexChange: onActiveIndexChange
|
|
155
|
-
}));
|
|
156
|
-
expect(screen.getByText('You are all set')).toBeInTheDocument();
|
|
157
|
-
});
|
|
158
|
-
it('clamps an activeIndex past the last page', () => {
|
|
159
|
-
render(_jsx(PushStoriesPreview, {
|
|
160
|
-
pages: pages,
|
|
161
|
-
activeIndex: 9
|
|
162
|
-
}));
|
|
163
|
-
expect(screen.getByText('You are all set')).toBeInTheDocument();
|
|
164
|
-
});
|
|
165
|
-
it('advances when the autoplay segment finishes and goes round after the last page', () => {
|
|
166
|
-
render(_jsx(PushStoriesPreview, {
|
|
167
|
-
pages: pages.slice(0, 2),
|
|
168
|
-
autoplay: true
|
|
169
|
-
}));
|
|
170
|
-
fireEvent.animationEnd(progressFill(0));
|
|
171
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
172
|
-
fireEvent.animationEnd(progressFill(1));
|
|
173
|
-
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
|
174
|
-
expect(progressFill(1)).toBeNull();
|
|
175
|
-
});
|
|
176
|
-
it('fills segments up to and including the current page without autoplay', () => {
|
|
177
|
-
const {
|
|
178
|
-
container
|
|
179
|
-
} = render(_jsx(PushStoriesPreview, {
|
|
180
|
-
pages: pages
|
|
181
|
-
}));
|
|
182
|
-
const filled = () => [...screen.getByTestId('push-stories-progress').children].filter(track => track.firstElementChild).length;
|
|
183
|
-
expect(filled()).toBe(1);
|
|
184
|
-
next();
|
|
185
|
-
expect(filled()).toBe(2);
|
|
186
|
-
next();
|
|
187
|
-
expect(filled()).toBe(3);
|
|
188
|
-
next();
|
|
189
|
-
expect(filled()).toBe(1);
|
|
190
|
-
expect(container.querySelectorAll('img')).toHaveLength(1);
|
|
191
|
-
});
|
|
192
|
-
it('starts the next segment from zero when a click interrupts autoplay', () => {
|
|
193
|
-
render(_jsx(PushStoriesPreview, {
|
|
194
|
-
pages: pages,
|
|
195
|
-
autoplay: true
|
|
196
|
-
}));
|
|
197
|
-
const interrupted = progressFill(0);
|
|
198
|
-
next();
|
|
199
|
-
expect(screen.getByText('Stay in the loop')).toBeInTheDocument();
|
|
200
|
-
expect(progressFill(0)).not.toBe(interrupted);
|
|
201
|
-
expect(progressFill(1)).not.toBeNull();
|
|
202
|
-
});
|
|
203
|
-
it('replays a single page instead of moving anywhere', () => {
|
|
204
|
-
render(_jsx(PushStoriesPreview, {
|
|
205
|
-
pages: pages.slice(0, 1),
|
|
206
|
-
autoplay: true
|
|
207
|
-
}));
|
|
208
|
-
const run = progressFill(0);
|
|
209
|
-
next();
|
|
210
|
-
expect(screen.getByTestId('push-stories-progress').children).toHaveLength(1);
|
|
211
|
-
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
|
212
|
-
expect(progressFill(0)).not.toBe(run);
|
|
213
|
-
});
|
|
214
|
-
it('draws a placeholder for a missing or broken image', () => {
|
|
215
|
-
const {
|
|
216
|
-
container
|
|
217
|
-
} = render(_jsx(PushStoriesPreview, {
|
|
218
|
-
pages: [{
|
|
219
|
-
title: 'No image'
|
|
220
|
-
}, pages[1]]
|
|
221
|
-
}));
|
|
222
|
-
expect(screen.getByTestId('push-stories-image-placeholder')).toBeInTheDocument();
|
|
223
|
-
next();
|
|
224
|
-
fireEvent.error(container.querySelector('img'));
|
|
225
|
-
expect(screen.getByTestId('push-stories-image-placeholder')).toBeInTheDocument();
|
|
226
|
-
});
|
|
227
|
-
it('drops the click target when not interactive', () => {
|
|
228
|
-
render(_jsx(PushStoriesPreview, {
|
|
229
|
-
pages: pages,
|
|
230
|
-
interactive: false
|
|
231
|
-
}));
|
|
232
|
-
expect(screen.queryByLabelText('Next page')).not.toBeInTheDocument();
|
|
233
|
-
});
|
|
234
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { RadioCard } from '../RadioCard';
|
|
4
|
-
describe('RadioCard', () => {
|
|
5
|
-
it('outlines the active card and dims the disabled one', () => {
|
|
6
|
-
const {
|
|
7
|
-
container,
|
|
8
|
-
rerender
|
|
9
|
-
} = render(_jsx(RadioCard, {
|
|
10
|
-
title: "Pro",
|
|
11
|
-
isActive: true,
|
|
12
|
-
onClick: jest.fn()
|
|
13
|
-
}));
|
|
14
|
-
const card = () => container.firstElementChild;
|
|
15
|
-
expect(getComputedStyle(card()).outline).toMatch(/^2px solid/);
|
|
16
|
-
rerender(_jsx(RadioCard, {
|
|
17
|
-
title: "Pro",
|
|
18
|
-
isDisabled: true,
|
|
19
|
-
onClick: jest.fn()
|
|
20
|
-
}));
|
|
21
|
-
expect(getComputedStyle(card()).opacity).toBe('0.5');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { RichmediaPreview } from '../RichmediaPreview';
|
|
4
|
-
describe('RichmediaPreview', () => {
|
|
5
|
-
it('sizes the container without width/height attributes', () => {
|
|
6
|
-
const {
|
|
7
|
-
container
|
|
8
|
-
} = render(_jsx(RichmediaPreview, {
|
|
9
|
-
name: "rm",
|
|
10
|
-
params: {},
|
|
11
|
-
content: "",
|
|
12
|
-
width: 300,
|
|
13
|
-
height: 500
|
|
14
|
-
}));
|
|
15
|
-
const box = container.firstElementChild;
|
|
16
|
-
expect(box).not.toHaveAttribute('width');
|
|
17
|
-
expect(box).not.toHaveAttribute('height');
|
|
18
|
-
expect(getComputedStyle(box).width).toBe('300px');
|
|
19
|
-
expect(getComputedStyle(box).height).toBe('500px');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { SandboxedHtmlFrame } from '../SandboxedHtmlFrame';
|
|
4
|
-
const HTML = '<p>content</p>';
|
|
5
|
-
function getFrame(container) {
|
|
6
|
-
const frame = container.querySelector('iframe');
|
|
7
|
-
if (!frame) {
|
|
8
|
-
throw new Error('iframe not rendered');
|
|
9
|
-
}
|
|
10
|
-
return frame;
|
|
11
|
-
}
|
|
12
|
-
describe('SandboxedHtmlFrame', () => {
|
|
13
|
-
it('isolates scripts in an opaque origin without same-origin access', () => {
|
|
14
|
-
const {
|
|
15
|
-
container
|
|
16
|
-
} = render(_jsx(SandboxedHtmlFrame, {
|
|
17
|
-
mode: "isolated",
|
|
18
|
-
title: "preview",
|
|
19
|
-
html: HTML
|
|
20
|
-
}));
|
|
21
|
-
const frame = getFrame(container);
|
|
22
|
-
expect(frame.getAttribute('sandbox')).toBe('allow-scripts');
|
|
23
|
-
expect(frame.getAttribute('srcdoc')).toBe(HTML);
|
|
24
|
-
expect(frame).toHaveAttribute('title', 'preview');
|
|
25
|
-
});
|
|
26
|
-
it('grants same-origin access but disables scripts in inspectable mode', () => {
|
|
27
|
-
const {
|
|
28
|
-
container
|
|
29
|
-
} = render(_jsx(SandboxedHtmlFrame, {
|
|
30
|
-
mode: "inspectable",
|
|
31
|
-
title: "stats",
|
|
32
|
-
html: HTML
|
|
33
|
-
}));
|
|
34
|
-
const frame = getFrame(container);
|
|
35
|
-
expect(frame.getAttribute('sandbox')).toBe('allow-same-origin');
|
|
36
|
-
expect(frame.getAttribute('sandbox')).not.toContain('allow-scripts');
|
|
37
|
-
});
|
|
38
|
-
it('never emits allow-scripts together with allow-same-origin', () => {
|
|
39
|
-
const isolated = render(_jsx(SandboxedHtmlFrame, {
|
|
40
|
-
mode: "isolated",
|
|
41
|
-
title: "a",
|
|
42
|
-
html: HTML
|
|
43
|
-
}));
|
|
44
|
-
const inspectable = render(_jsx(SandboxedHtmlFrame, {
|
|
45
|
-
mode: "inspectable",
|
|
46
|
-
title: "b",
|
|
47
|
-
html: HTML
|
|
48
|
-
}));
|
|
49
|
-
[isolated, inspectable].forEach(({
|
|
50
|
-
container
|
|
51
|
-
}) => {
|
|
52
|
-
const sandbox = getFrame(container).getAttribute('sandbox') ?? '';
|
|
53
|
-
const hasBoth = sandbox.includes('allow-scripts') && sandbox.includes('allow-same-origin');
|
|
54
|
-
expect(hasBoth).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { CircularSkeleton, RectangularSkeleton, TextSkeletonTag } from '../styles';
|
|
4
|
-
import { TextSkeleton } from '../TextSkeleton';
|
|
5
|
-
describe('RectangularSkeleton', () => {
|
|
6
|
-
it('keeps style props off the DOM and still paints them', () => {
|
|
7
|
-
render(_jsx(RectangularSkeleton, {
|
|
8
|
-
"data-testid": "rect",
|
|
9
|
-
width: 120,
|
|
10
|
-
height: 16,
|
|
11
|
-
color: "red",
|
|
12
|
-
borderRadius: 4
|
|
13
|
-
}));
|
|
14
|
-
const node = screen.getByTestId('rect');
|
|
15
|
-
expect(node).not.toHaveAttribute('width');
|
|
16
|
-
expect(node).not.toHaveAttribute('height');
|
|
17
|
-
expect(node).not.toHaveAttribute('color');
|
|
18
|
-
expect(node).not.toHaveAttribute('borderradius');
|
|
19
|
-
expect(getComputedStyle(node)).toMatchObject({
|
|
20
|
-
width: '120px',
|
|
21
|
-
height: '16px',
|
|
22
|
-
backgroundColor: 'rgb(255, 0, 0)',
|
|
23
|
-
borderRadius: '4px'
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
it('still forwards regular attributes', () => {
|
|
27
|
-
render(_jsx(RectangularSkeleton, {
|
|
28
|
-
"data-testid": "rect",
|
|
29
|
-
title: "loading",
|
|
30
|
-
"aria-busy": "true",
|
|
31
|
-
width: 1,
|
|
32
|
-
height: 1
|
|
33
|
-
}));
|
|
34
|
-
const node = screen.getByTestId('rect');
|
|
35
|
-
expect(node).toHaveAttribute('title', 'loading');
|
|
36
|
-
expect(node).toHaveAttribute('aria-busy', 'true');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
describe('CircularSkeleton', () => {
|
|
40
|
-
it('keeps style props off the DOM and still paints them', () => {
|
|
41
|
-
render(_jsx(CircularSkeleton, {
|
|
42
|
-
"data-testid": "circle",
|
|
43
|
-
"aria-label": "avatar",
|
|
44
|
-
diameter: 32,
|
|
45
|
-
color: "red"
|
|
46
|
-
}));
|
|
47
|
-
const node = screen.getByTestId('circle');
|
|
48
|
-
expect(node).not.toHaveAttribute('diameter');
|
|
49
|
-
expect(node).not.toHaveAttribute('color');
|
|
50
|
-
expect(node).toHaveAttribute('aria-label', 'avatar');
|
|
51
|
-
expect(getComputedStyle(node)).toMatchObject({
|
|
52
|
-
width: '32px',
|
|
53
|
-
height: '32px',
|
|
54
|
-
backgroundColor: 'rgb(255, 0, 0)'
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe('TextSkeleton', () => {
|
|
59
|
-
it('denies borderRadius and color in shouldForwardProp, which SC 6 uses instead of isPropValid', () => {
|
|
60
|
-
const {
|
|
61
|
-
shouldForwardProp
|
|
62
|
-
} = TextSkeletonTag;
|
|
63
|
-
expect(shouldForwardProp?.('borderRadius')).toBe(false);
|
|
64
|
-
expect(shouldForwardProp?.('color')).toBe(false);
|
|
65
|
-
expect(shouldForwardProp?.('title')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('keeps style props off the DOM and still paints them', () => {
|
|
68
|
-
render(_jsx(TextSkeleton, {
|
|
69
|
-
"data-testid": "text",
|
|
70
|
-
width: 160,
|
|
71
|
-
color: "red",
|
|
72
|
-
borderRadius: "8px"
|
|
73
|
-
}));
|
|
74
|
-
const node = screen.getByTestId('text');
|
|
75
|
-
expect(node).not.toHaveAttribute('color');
|
|
76
|
-
expect(node).not.toHaveAttribute('borderradius');
|
|
77
|
-
expect(node).toHaveAttribute('data-testid', 'text');
|
|
78
|
-
expect(getComputedStyle(node)).toMatchObject({
|
|
79
|
-
width: '160px',
|
|
80
|
-
color: 'rgb(255, 0, 0)',
|
|
81
|
-
backgroundColor: 'rgb(255, 0, 0)',
|
|
82
|
-
borderRadius: '8px'
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
it('still renders a div with inline width and an inline span without it', () => {
|
|
86
|
-
render(_jsx(TextSkeleton, {
|
|
87
|
-
"data-testid": "block",
|
|
88
|
-
width: 160
|
|
89
|
-
}));
|
|
90
|
-
render(_jsx(TextSkeleton, {
|
|
91
|
-
"data-testid": "inline",
|
|
92
|
-
children: "abc"
|
|
93
|
-
}));
|
|
94
|
-
expect(screen.getByTestId('block').tagName).toBe('DIV');
|
|
95
|
-
expect(screen.getByTestId('block')).toHaveStyle({
|
|
96
|
-
width: '160px'
|
|
97
|
-
});
|
|
98
|
-
expect(screen.getByTestId('inline').tagName).toBe('SPAN');
|
|
99
|
-
expect(screen.getByTestId('inline')).not.toHaveAttribute('style');
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import { Spinner } from '../Spinner';
|
|
4
|
-
describe('Spinner', () => {
|
|
5
|
-
it('sizes the box from `size` without leaking it to the DOM', () => {
|
|
6
|
-
const {
|
|
7
|
-
container
|
|
8
|
-
} = render(_jsx(Spinner, {
|
|
9
|
-
size: "medium"
|
|
10
|
-
}));
|
|
11
|
-
const box = container.firstElementChild;
|
|
12
|
-
expect(box).not.toHaveAttribute('size');
|
|
13
|
-
expect(getComputedStyle(box).width).toBe('24px');
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { Switch } from '../Switch';
|
|
4
|
-
describe('Switch', () => {
|
|
5
|
-
it('flips on a click on the label, not only on the toggle', () => {
|
|
6
|
-
const onChange = jest.fn();
|
|
7
|
-
render(_jsx(Switch, {
|
|
8
|
-
enabled: false,
|
|
9
|
-
onChange: onChange,
|
|
10
|
-
children: "Save inbox"
|
|
11
|
-
}));
|
|
12
|
-
fireEvent.click(screen.getByText('Save inbox'));
|
|
13
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
14
|
-
});
|
|
15
|
-
it('flips on a click on the toggle', () => {
|
|
16
|
-
const onChange = jest.fn();
|
|
17
|
-
const {
|
|
18
|
-
container
|
|
19
|
-
} = render(_jsx(Switch, {
|
|
20
|
-
enabled: true,
|
|
21
|
-
onChange: onChange,
|
|
22
|
-
children: "Save inbox"
|
|
23
|
-
}));
|
|
24
|
-
const box = container.querySelector('[tabindex="0"]');
|
|
25
|
-
if (!box) {
|
|
26
|
-
throw new Error('toggle not rendered');
|
|
27
|
-
}
|
|
28
|
-
fireEvent.click(box);
|
|
29
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
30
|
-
});
|
|
31
|
-
it('stays silent while disabled, label and toggle alike', () => {
|
|
32
|
-
const onChange = jest.fn();
|
|
33
|
-
const {
|
|
34
|
-
container
|
|
35
|
-
} = render(_jsx(Switch, {
|
|
36
|
-
isDisabled: true,
|
|
37
|
-
onChange: onChange,
|
|
38
|
-
children: "Save inbox"
|
|
39
|
-
}));
|
|
40
|
-
fireEvent.click(screen.getByText('Save inbox'));
|
|
41
|
-
fireEvent.click(container.querySelector('[tabindex="0"]'));
|
|
42
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { Tab, TabBar, Tabs } from '..';
|
|
4
|
-
describe('TabBar', () => {
|
|
5
|
-
it('adds a title column only when a title is given, without a hasTitle attribute', () => {
|
|
6
|
-
render(_jsx(Tabs, {
|
|
7
|
-
activeCode: "a",
|
|
8
|
-
onChange: jest.fn(),
|
|
9
|
-
children: _jsx(TabBar, {
|
|
10
|
-
title: "Title",
|
|
11
|
-
"data-testid": "bar",
|
|
12
|
-
children: _jsx(Tab, {
|
|
13
|
-
code: "a",
|
|
14
|
-
children: "A"
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
}));
|
|
18
|
-
const bar = screen.getByTestId('bar');
|
|
19
|
-
expect(bar).not.toHaveAttribute('hastitle');
|
|
20
|
-
expect(getComputedStyle(bar).gridTemplateColumns).toBe('max-content 1fr');
|
|
21
|
-
});
|
|
22
|
-
it('uses a single column without a title', () => {
|
|
23
|
-
render(_jsx(Tabs, {
|
|
24
|
-
activeCode: "a",
|
|
25
|
-
onChange: jest.fn(),
|
|
26
|
-
children: _jsx(TabBar, {
|
|
27
|
-
"data-testid": "bar",
|
|
28
|
-
children: _jsx(Tab, {
|
|
29
|
-
code: "a",
|
|
30
|
-
children: "A"
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
}));
|
|
34
|
-
expect(getComputedStyle(screen.getByTestId('bar')).gridTemplateColumns).toBe('1fr');
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { Toast } from '../Toast';
|
|
4
|
-
describe('Toast', () => {
|
|
5
|
-
it('slides in when open and keeps `open`/`type` off the DOM', () => {
|
|
6
|
-
render(_jsx(Toast, {
|
|
7
|
-
open: true,
|
|
8
|
-
toast: {
|
|
9
|
-
title: 'Saved',
|
|
10
|
-
type: 'success',
|
|
11
|
-
duration: false
|
|
12
|
-
},
|
|
13
|
-
onClose: jest.fn()
|
|
14
|
-
}));
|
|
15
|
-
const root = screen.getByText('Saved').closest('div[class]')?.parentElement;
|
|
16
|
-
expect(root).not.toHaveAttribute('open');
|
|
17
|
-
expect(root).not.toHaveAttribute('type');
|
|
18
|
-
expect(getComputedStyle(root).top).toBe('50px');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { WhatsAppAttachment } from '../components/WhatsAppAttachment';
|
|
4
|
-
const IMAGE = {
|
|
5
|
-
name: 'promo.jpg',
|
|
6
|
-
source: 'https://example.invalid/promo.jpg',
|
|
7
|
-
kind: 'image'
|
|
8
|
-
};
|
|
9
|
-
describe('WhatsAppAttachment', () => {
|
|
10
|
-
it('labels a loading image without leaking the file name', () => {
|
|
11
|
-
render(_jsx(WhatsAppAttachment, {
|
|
12
|
-
attachment: IMAGE
|
|
13
|
-
}));
|
|
14
|
-
const image = screen.getByRole('img');
|
|
15
|
-
expect(image).toHaveAttribute('alt', 'Attached image');
|
|
16
|
-
expect(image.getAttribute('alt')).not.toContain('promo.jpg');
|
|
17
|
-
});
|
|
18
|
-
it('drops the image for the placeholder once the source fails', () => {
|
|
19
|
-
render(_jsx(WhatsAppAttachment, {
|
|
20
|
-
attachment: IMAGE
|
|
21
|
-
}));
|
|
22
|
-
fireEvent.error(screen.getByRole('img'));
|
|
23
|
-
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
it('retries a corrected source instead of keeping the placeholder', () => {
|
|
26
|
-
const {
|
|
27
|
-
rerender
|
|
28
|
-
} = render(_jsx(WhatsAppAttachment, {
|
|
29
|
-
attachment: IMAGE
|
|
30
|
-
}));
|
|
31
|
-
fireEvent.error(screen.getByRole('img'));
|
|
32
|
-
rerender(_jsx(WhatsAppAttachment, {
|
|
33
|
-
attachment: {
|
|
34
|
-
...IMAGE,
|
|
35
|
-
source: 'https://example.invalid/fixed.jpg'
|
|
36
|
-
}
|
|
37
|
-
}));
|
|
38
|
-
expect(screen.getByRole('img')).toHaveAttribute('src', 'https://example.invalid/fixed.jpg');
|
|
39
|
-
});
|
|
40
|
-
it('hides an unreachable document poster but keeps the card', () => {
|
|
41
|
-
render(_jsx(WhatsAppAttachment, {
|
|
42
|
-
attachment: {
|
|
43
|
-
name: 'Price list.pdf',
|
|
44
|
-
source: 'https://example.invalid/price.pdf',
|
|
45
|
-
kind: 'document',
|
|
46
|
-
thumbnailSource: 'https://example.invalid/poster.jpg'
|
|
47
|
-
}
|
|
48
|
-
}));
|
|
49
|
-
fireEvent.error(screen.getByRole('img'));
|
|
50
|
-
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
51
|
-
expect(screen.getByText('Price list.pdf')).toBeInTheDocument();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|