@instructure/ui-modal 10.19.2-snapshot-2 → 10.19.2-snapshot-4

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.
@@ -1,474 +0,0 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["label"];
3
- var _Modal, _Modal2, _Modal$Body, _Modal3, _Modal4, _View, _Modal5, _Modal$Body2, _Modal$Body3, _Modal$Body4, _Modal$Body5, _Modal$Body6, _Modal$Body7, _Modal6, _Modal7, _input, _Modal$Header, _Modal$Body8, _Modal$Footer;
4
- /*
5
- * The MIT License (MIT)
6
- *
7
- * Copyright (c) 2015 - present Instructure, Inc.
8
- *
9
- * Permission is hereby granted, free of charge, to any person obtaining a copy
10
- * of this software and associated documentation files (the "Software"), to deal
11
- * in the Software without restriction, including without limitation the rights
12
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- * copies of the Software, and to permit persons to whom the Software is
14
- * furnished to do so, subject to the following conditions:
15
- *
16
- * The above copyright notice and this permission notice shall be included in all
17
- * copies or substantial portions of the Software.
18
- *
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- * SOFTWARE.
26
- */
27
-
28
- import { Component } from 'react';
29
- import { render, waitFor } from '@testing-library/react';
30
- import { vi } from 'vitest';
31
- import userEvent from '@testing-library/user-event';
32
- import '@testing-library/jest-dom';
33
- import { Modal } from '../index';
34
- import { View } from '@instructure/ui-view';
35
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
36
- describe('<Modal />', () => {
37
- let consoleWarningMock;
38
- let consoleErrorMock;
39
- const originalScroll = window.scroll;
40
- beforeEach(() => {
41
- // Mocking console to prevent test output pollution and expect for messages
42
- consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
43
- consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
44
- });
45
- afterEach(() => {
46
- consoleWarningMock.mockRestore();
47
- consoleErrorMock.mockRestore();
48
- });
49
- beforeAll(() => {
50
- // Mocking window.scroll to prevent test output pollution
51
- Object.defineProperty(window, 'scroll', {
52
- value: vi.fn(),
53
- writable: true
54
- });
55
- });
56
- afterAll(() => {
57
- window.scroll = originalScroll;
58
- });
59
- it('should render nothing and have a node with no parent when closed', () => {
60
- const _render = render(_Modal || (_Modal = _jsx(Modal, {
61
- label: "Modal Dialog",
62
- shouldReturnFocus: false,
63
- children: _jsx(Modal.Body, {
64
- children: "Foo Bar Baz"
65
- })
66
- }))),
67
- container = _render.container;
68
- expect(container.firstChild).not.toBeInTheDocument();
69
- });
70
- it('should apply theme overrides when open', async () => {
71
- const testFont = 'test-font';
72
- const bodyText = 'Modal-body-text';
73
- const _render2 = render(_jsx(Modal, {
74
- open: true,
75
- size: "small",
76
- label: "Modal Dialog",
77
- shouldReturnFocus: false,
78
- themeOverride: {
79
- fontFamily: testFont
80
- },
81
- children: _jsx(Modal.Body, {
82
- children: bodyText
83
- })
84
- })),
85
- findByText = _render2.findByText,
86
- findByRole = _render2.findByRole;
87
- const modalBody = await findByText(bodyText);
88
- const dialog = await findByRole('dialog');
89
- const dialogStyle = window.getComputedStyle(dialog);
90
- expect(modalBody).toBeInTheDocument();
91
- expect(dialogStyle.fontFamily).toBe(testFont);
92
- });
93
- it('should render its own positioning context if constrained to parent', async () => {
94
- const _render3 = render(_Modal2 || (_Modal2 = _jsx(Modal, {
95
- open: true,
96
- label: "Modal Dialog",
97
- shouldReturnFocus: false,
98
- constrain: "parent",
99
- children: _jsx(Modal.Body, {
100
- children: "Foo Bar Baz"
101
- })
102
- }))),
103
- findByRole = _render3.findByRole;
104
- const dialog = await findByRole('dialog');
105
- const constrain = document.querySelector("[class*='constrainContext']");
106
- expect(dialog).toBeInTheDocument();
107
- expect(constrain).toBeInTheDocument();
108
- });
109
- it("should not inherit its parent's font color", async () => {
110
- const _render4 = render(_jsx("div", {
111
- style: {
112
- color: 'rgb(255, 255, 255)'
113
- },
114
- children: _jsx(Modal, {
115
- open: true,
116
- label: "Modal Dialog",
117
- shouldReturnFocus: false,
118
- constrain: "parent",
119
- themeOverride: {
120
- textColor: 'rgb(0, 0, 0)'
121
- },
122
- children: _Modal$Body || (_Modal$Body = _jsx(Modal.Body, {
123
- children: "Foo Bar Baz"
124
- }))
125
- })
126
- })),
127
- findByRole = _render4.findByRole;
128
- const dialog = await findByRole('dialog');
129
- const dialogStyle = window.getComputedStyle(dialog);
130
- expect(dialog).toBeInTheDocument();
131
- expect(dialogStyle.color).toBe('rgb(0, 0, 0)');
132
- });
133
- it('should pass `as` prop to the dialog', async () => {
134
- const _render5 = render(_Modal3 || (_Modal3 = _jsx(Modal, {
135
- open: true,
136
- label: "Modal Dialog",
137
- shouldReturnFocus: false,
138
- children: _jsx(Modal.Body, {
139
- children: "Foo Bar Baz"
140
- })
141
- }))),
142
- findByRole = _render5.findByRole,
143
- rerender = _render5.rerender;
144
- const dialog = await findByRole('dialog');
145
- expect(dialog).toBeInTheDocument();
146
- expect(dialog.tagName).toBe('SPAN');
147
- rerender(_Modal4 || (_Modal4 = _jsx(Modal, {
148
- as: "form",
149
- open: true,
150
- label: "Modal Dialog",
151
- shouldReturnFocus: false,
152
- children: _jsx(Modal.Body, {
153
- children: "Foo Bar Baz"
154
- })
155
- })));
156
- const dialogForm = await findByRole('dialog');
157
- expect(dialogForm.tagName).toBe('FORM');
158
- });
159
- it('should handle null children', async () => {
160
- const bodyText = 'Modal-body-text';
161
- const _render6 = render(_jsxs(Modal, {
162
- open: true,
163
- label: "Modal Dialog",
164
- shouldReturnFocus: false,
165
- children: [null, _jsx(Modal.Body, {
166
- children: bodyText
167
- }), null]
168
- })),
169
- findByText = _render6.findByText;
170
- const modalBody = await findByText(bodyText);
171
- expect(modalBody).toBeInTheDocument();
172
- });
173
- it('should handle custom children', async () => {
174
- const bodyText = 'Modal-body-text';
175
- const _render7 = render(_jsxs(Modal, {
176
- open: true,
177
- label: "Modal Dialog",
178
- shouldReturnFocus: false,
179
- children: [_View || (_View = _jsx(View, {
180
- children: "This is a custom child"
181
- })), _jsx(Modal.Body, {
182
- children: bodyText
183
- })]
184
- })),
185
- findByText = _render7.findByText;
186
- const modalBody = await findByText(bodyText);
187
- const customChild = await findByText('This is a custom child');
188
- expect(modalBody).toBeInTheDocument();
189
- expect(customChild).toBeInTheDocument();
190
- });
191
- it('should apply the aria attributes', async () => {
192
- const _render8 = render(_Modal5 || (_Modal5 = _jsx(Modal, {
193
- open: true,
194
- label: "Modal Dialog",
195
- shouldReturnFocus: false,
196
- children: _jsx(Modal.Body, {
197
- children: "Foo Bar Baz"
198
- })
199
- }))),
200
- findByRole = _render8.findByRole;
201
- const dialog = await findByRole('dialog');
202
- expect(dialog).toBeInTheDocument();
203
- expect(dialog).toHaveAttribute('aria-label', 'Modal Dialog');
204
- });
205
- it('should use transition', async () => {
206
- const onEnter = vi.fn();
207
- const onEntering = vi.fn();
208
- const onEntered = vi.fn();
209
- const _render9 = render(_jsx(Modal, {
210
- open: true,
211
- onEnter: onEnter,
212
- onEntering: onEntering,
213
- onEntered: onEntered,
214
- transition: "fade",
215
- label: "Modal Dialog",
216
- shouldReturnFocus: false,
217
- children: _Modal$Body2 || (_Modal$Body2 = _jsx(Modal.Body, {
218
- children: "Foo Bar Baz"
219
- }))
220
- })),
221
- findByRole = _render9.findByRole;
222
- const dialog = await findByRole('dialog');
223
- expect(dialog).toBeInTheDocument();
224
- await waitFor(() => {
225
- expect(onEnter).toHaveBeenCalled();
226
- expect(onEntering).toHaveBeenCalled();
227
- expect(onEntered).toHaveBeenCalled();
228
- });
229
- });
230
- it('should support onOpen prop', async () => {
231
- const onOpen = vi.fn();
232
- const _render10 = render(_jsx(Modal, {
233
- open: true,
234
- onOpen: onOpen,
235
- label: "Modal Dialog",
236
- shouldReturnFocus: false,
237
- children: _Modal$Body3 || (_Modal$Body3 = _jsx(Modal.Body, {
238
- children: "Foo Bar Baz"
239
- }))
240
- })),
241
- findByRole = _render10.findByRole;
242
- const dialog = await findByRole('dialog');
243
- expect(dialog).toBeInTheDocument();
244
- await waitFor(() => {
245
- expect(onOpen).toHaveBeenCalled();
246
- });
247
- });
248
- it('should support onClose prop', async () => {
249
- const onClose = vi.fn();
250
- const _render11 = render(_jsx(Modal, {
251
- open: true,
252
- onClose: onClose,
253
- label: "Modal Dialog",
254
- shouldReturnFocus: false,
255
- children: _Modal$Body4 || (_Modal$Body4 = _jsx(Modal.Body, {
256
- children: "Foo Bar Baz"
257
- }))
258
- })),
259
- findByRole = _render11.findByRole,
260
- rerender = _render11.rerender;
261
- const dialog = await findByRole('dialog');
262
- expect(dialog).toBeInTheDocument();
263
- rerender(_jsx(Modal, {
264
- open: false,
265
- onClose: onClose,
266
- label: "Modal Dialog",
267
- shouldReturnFocus: false,
268
- children: _Modal$Body5 || (_Modal$Body5 = _jsx(Modal.Body, {
269
- children: "Foo Bar Baz"
270
- }))
271
- }));
272
- await waitFor(() => {
273
- expect(onClose).toHaveBeenCalled();
274
- });
275
- });
276
- it('should dismiss when overlay clicked by default', async () => {
277
- const onDismiss = vi.fn();
278
- const _render12 = render(_jsx(Modal, {
279
- open: true,
280
- onDismiss: onDismiss,
281
- label: "Modal Dialog",
282
- shouldReturnFocus: false,
283
- children: _Modal$Body6 || (_Modal$Body6 = _jsx(Modal.Body, {
284
- children: "Modal Text"
285
- }))
286
- })),
287
- findByText = _render12.findByText;
288
- const modalBody = await findByText('Modal Text');
289
- expect(modalBody).toBeInTheDocument();
290
- await waitFor(() => {
291
- userEvent.click(document.body);
292
- expect(onDismiss).toHaveBeenCalled();
293
- });
294
- });
295
- it('should NOT dismiss when overlay clicked with shouldCloseOnDocumentClick=false', async () => {
296
- const onDismiss = vi.fn();
297
- const onClickOuter = vi.fn();
298
- const _render13 = render(_jsxs("div", {
299
- children: [_jsx("button", {
300
- "data-testid": "outer-element",
301
- onClick: onClickOuter,
302
- children: "for dismiss"
303
- }), _jsx(Modal, {
304
- open: true,
305
- onDismiss: onDismiss,
306
- label: "Modal Dialog",
307
- shouldReturnFocus: false,
308
- shouldCloseOnDocumentClick: false,
309
- children: _Modal$Body7 || (_Modal$Body7 = _jsxs(Modal.Body, {
310
- children: ["Foo Bar Baz ", _jsx("button", {
311
- children: "click me"
312
- })]
313
- }))
314
- })]
315
- })),
316
- findByRole = _render13.findByRole,
317
- getByTestId = _render13.getByTestId;
318
- const dialog = await findByRole('dialog');
319
- expect(dialog).toBeInTheDocument();
320
- userEvent.click(getByTestId('outer-element'));
321
- await waitFor(() => {
322
- expect(onClickOuter).toHaveBeenCalled();
323
- expect(onDismiss).not.toHaveBeenCalled();
324
- expect(dialog).toBeInTheDocument();
325
- });
326
- });
327
- it('should render children', async () => {
328
- const _render14 = render(_Modal6 || (_Modal6 = _jsx(Modal, {
329
- open: true,
330
- label: "Modal Dialog",
331
- shouldReturnFocus: false,
332
- children: _jsx(Modal.Body, {
333
- children: _jsx("button", {
334
- children: "Cancel"
335
- })
336
- })
337
- }))),
338
- findByText = _render14.findByText;
339
- const cancelButton = await findByText('Cancel');
340
- expect(cancelButton).toBeInTheDocument();
341
- });
342
- describe('children validation', () => {
343
- it('should pass validation when children are valid', async () => {
344
- const _render15 = render(_Modal7 || (_Modal7 = _jsxs(Modal, {
345
- open: true,
346
- label: "Modal Dialog",
347
- shouldReturnFocus: false,
348
- children: [_jsx(Modal.Header, {
349
- children: "Hello World"
350
- }), _jsx(Modal.Body, {
351
- children: "Foo Bar Baz"
352
- }), _jsx(Modal.Footer, {
353
- children: _jsx("button", {
354
- children: "Cancel"
355
- })
356
- })]
357
- }))),
358
- findByRole = _render15.findByRole;
359
- const dialog = await findByRole('dialog');
360
- expect(dialog).toBeInTheDocument();
361
- expect(consoleErrorMock).not.toHaveBeenCalled();
362
- });
363
- it('should pass inverse variant to children when set', async () => {
364
- let headerRef = null;
365
- let bodyRef = null;
366
- let footerRef = null;
367
- const _render16 = render(_jsxs(Modal, {
368
- open: true,
369
- label: "Dark Modal",
370
- shouldReturnFocus: false,
371
- variant: "inverse",
372
- children: [_jsx(Modal.Header, {
373
- ref: el => headerRef = el,
374
- children: "header"
375
- }), _jsx(Modal.Body, {
376
- ref: el => bodyRef = el,
377
- children: "body"
378
- }), _jsx(Modal.Footer, {
379
- ref: el => footerRef = el,
380
- children: "footer"
381
- })]
382
- })),
383
- findByRole = _render16.findByRole;
384
- const dialog = await findByRole('dialog');
385
- expect(dialog).toBeInTheDocument();
386
- expect(headerRef.props.variant).toBe('inverse');
387
- expect(bodyRef.props.variant).toBe('inverse');
388
- expect(footerRef.props.variant).toBe('inverse');
389
- });
390
- it('should pass overflow to Modal.Body', async () => {
391
- let bodyRef = null;
392
- const _render17 = render(_jsx(Modal, {
393
- open: true,
394
- label: "Modal",
395
- shouldReturnFocus: false,
396
- overflow: "fit",
397
- children: _jsx(Modal.Body, {
398
- ref: el => bodyRef = el,
399
- children: "body"
400
- })
401
- })),
402
- findByRole = _render17.findByRole;
403
- const dialog = await findByRole('dialog');
404
- expect(dialog).toBeInTheDocument();
405
- expect(bodyRef.props.overflow).toBe('fit');
406
- });
407
- });
408
- describe('managed focus', () => {
409
- var _ModalExample2;
410
- class ModalExample extends Component {
411
- render() {
412
- const _this$props = this.props,
413
- label = _this$props.label,
414
- props = _objectWithoutProperties(_this$props, _excluded);
415
- return _jsxs("div", {
416
- children: [_input || (_input = _jsx("input", {
417
- type: "text"
418
- })), _jsxs(Modal, {
419
- label: label,
420
- ...props,
421
- children: [_Modal$Header || (_Modal$Header = _jsx(Modal.Header, {
422
- children: _jsx("button", {
423
- children: "Close"
424
- })
425
- })), _Modal$Body8 || (_Modal$Body8 = _jsxs(Modal.Body, {
426
- children: [_jsx("input", {
427
- type: "text",
428
- id: "input-one",
429
- "data-testid": "input-first"
430
- }), _jsx("input", {
431
- type: "text",
432
- id: "input-two",
433
- "data-testid": "input-second"
434
- })]
435
- })), _Modal$Footer || (_Modal$Footer = _jsx(Modal.Footer, {
436
- children: _jsx("button", {
437
- children: "Cancel"
438
- })
439
- }))]
440
- })]
441
- });
442
- }
443
- }
444
- ModalExample.displayName = "ModalExample";
445
- ModalExample.propTypes = {
446
- // eslint-disable-next-line react/forbid-foreign-prop-types
447
- ...Modal.propTypes
448
- };
449
- it('should focus closeButton by default', async () => {
450
- const _render18 = render(_ModalExample2 || (_ModalExample2 = _jsx(ModalExample, {
451
- open: true,
452
- label: "A Modal"
453
- }))),
454
- findByText = _render18.findByText;
455
- const closeButton = await findByText('Close');
456
- expect(closeButton).toBeInTheDocument();
457
- await waitFor(() => {
458
- expect(document.activeElement).toBe(closeButton);
459
- });
460
- });
461
- it('should take a prop for finding default focus', async () => {
462
- const _render19 = render(_jsx(ModalExample, {
463
- open: true,
464
- label: "A Modal",
465
- defaultFocusElement: () => document.getElementById('input-one')
466
- })),
467
- findByTestId = _render19.findByTestId;
468
- const input = await findByTestId('input-first');
469
- await waitFor(() => {
470
- expect(input).toHaveFocus();
471
- });
472
- });
473
- });
474
- });
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- require("@testing-library/jest-dom");
7
- var _uiColorUtils = require("@instructure/ui-color-utils");
8
- var _uiThemes = _interopRequireDefault(require("@instructure/ui-themes"));
9
- var _View = require("@instructure/ui-view/lib/View");
10
- var _index = require("../index");
11
- var _theme = _interopRequireDefault(require("../theme"));
12
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
13
- var _ModalBody, _ModalBody2, _ModalBody3;
14
- /*
15
- * The MIT License (MIT)
16
- *
17
- * Copyright (c) 2015 - present Instructure, Inc.
18
- *
19
- * Permission is hereby granted, free of charge, to any person obtaining a copy
20
- * of this software and associated documentation files (the "Software"), to deal
21
- * in the Software without restriction, including without limitation the rights
22
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
- * copies of the Software, and to permit persons to whom the Software is
24
- * furnished to do so, subject to the following conditions:
25
- *
26
- * The above copyright notice and this permission notice shall be included in all
27
- * copies or substantial portions of the Software.
28
- *
29
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
- * SOFTWARE.
36
- */
37
- const BODY_TEXT = 'Modal-body-text';
38
- describe('<ModalBody />', () => {
39
- it('should render', async () => {
40
- const _render = (0, _react.render)(_ModalBody || (_ModalBody = (0, _jsxRuntime.jsx)(_index.ModalBody, {
41
- children: BODY_TEXT
42
- }))),
43
- findByText = _render.findByText;
44
- const modalBody = await findByText(BODY_TEXT);
45
- expect(modalBody).toBeInTheDocument();
46
- });
47
- it('should set inverse styles', async () => {
48
- const themeVariables = (0, _theme.default)(_uiThemes.default);
49
- const _render2 = (0, _react.render)(_ModalBody2 || (_ModalBody2 = (0, _jsxRuntime.jsx)(_index.ModalBody, {
50
- variant: "inverse",
51
- children: BODY_TEXT
52
- }))),
53
- findByText = _render2.findByText;
54
- const modalBody = await findByText(BODY_TEXT);
55
- const modalBodyStyle = window.getComputedStyle(modalBody);
56
- const bodyBackground = (0, _uiColorUtils.color2hex)(modalBodyStyle.getPropertyValue('background-color'));
57
- expect(modalBody).toBeInTheDocument();
58
- expect(bodyBackground).toBe(themeVariables.inverseBackground);
59
- });
60
- it('should set the same width and height as the parent when overflow is set to fit', async () => {
61
- const _render3 = (0, _react.render)((0, _jsxRuntime.jsx)("div", {
62
- style: {
63
- width: '500px',
64
- height: '600px'
65
- },
66
- children: _ModalBody3 || (_ModalBody3 = (0, _jsxRuntime.jsx)(_index.ModalBody, {
67
- overflow: "fit",
68
- children: BODY_TEXT
69
- }))
70
- })),
71
- findByText = _render3.findByText;
72
- const modalBody = await findByText(BODY_TEXT);
73
- const modalBodyStyle = window.getComputedStyle(modalBody);
74
- expect(modalBodyStyle.width).toBe('100%');
75
- expect(modalBodyStyle.height).toBe('100%');
76
- });
77
- describe('when passing down props to View', () => {
78
- const allowedProps = {
79
- padding: 'small',
80
- elementRef: () => {},
81
- as: 'section'
82
- };
83
- const allProps = _View.View.allowedProps.filter(prop => prop !== 'children');
84
- allProps.forEach(prop => {
85
- if (prop in allowedProps) {
86
- it(`should allow the '${prop}' prop`, () => {
87
- const consoleErrorSpy = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
88
- const props = {
89
- [prop]: allowedProps[prop]
90
- };
91
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.ModalBody, {
92
- ...props
93
- }));
94
- expect(consoleErrorSpy).not.toHaveBeenCalled();
95
- consoleErrorSpy.mockRestore();
96
- });
97
- } else {
98
- it(`should NOT allow the '${prop}' prop`, () => {
99
- const expectedErrorMessage = `prop '${prop}' is not allowed.`;
100
- const consoleErrorSpy = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
101
- const props = {
102
- [prop]: 'NOT_ALLOWED_VALUE'
103
- };
104
- (0, _react.render)((0, _jsxRuntime.jsx)(_index.ModalBody, {
105
- ...props
106
- }));
107
- expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining(expectedErrorMessage), expect.any(String));
108
- consoleErrorSpy.mockRestore();
109
- });
110
- }
111
- });
112
- });
113
- });
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _react = require("@testing-library/react");
5
- require("@testing-library/jest-dom");
6
- var _uiThemes = _interopRequireDefault(require("@instructure/ui-themes"));
7
- var _uiColorUtils = require("@instructure/ui-color-utils");
8
- var _index = require("../index");
9
- var _theme = _interopRequireDefault(require("../theme"));
10
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
- var _ModalFooter, _ModalFooter2;
12
- /*
13
- * The MIT License (MIT)
14
- *
15
- * Copyright (c) 2015 - present Instructure, Inc.
16
- *
17
- * Permission is hereby granted, free of charge, to any person obtaining a copy
18
- * of this software and associated documentation files (the "Software"), to deal
19
- * in the Software without restriction, including without limitation the rights
20
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- * copies of the Software, and to permit persons to whom the Software is
22
- * furnished to do so, subject to the following conditions:
23
- *
24
- * The above copyright notice and this permission notice shall be included in all
25
- * copies or substantial portions of the Software.
26
- *
27
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
- * SOFTWARE.
34
- */
35
- const FOOTER_TEXT = 'Modal-footer-text';
36
- describe('<ModalFooter />', () => {
37
- it('should render', async () => {
38
- const _render = (0, _react.render)(_ModalFooter || (_ModalFooter = (0, _jsxRuntime.jsx)(_index.ModalFooter, {
39
- children: FOOTER_TEXT
40
- }))),
41
- findByText = _render.findByText;
42
- const modalFooter = await findByText(FOOTER_TEXT);
43
- expect(modalFooter).toBeInTheDocument();
44
- });
45
- it('should set inverse styles', async () => {
46
- const themeVariables = (0, _theme.default)(_uiThemes.default);
47
- const _render2 = (0, _react.render)(_ModalFooter2 || (_ModalFooter2 = (0, _jsxRuntime.jsx)(_index.ModalFooter, {
48
- variant: "inverse",
49
- children: FOOTER_TEXT
50
- }))),
51
- findByText = _render2.findByText;
52
- const modalFooter = await findByText(FOOTER_TEXT);
53
- const modalFooterStyle = window.getComputedStyle(modalFooter);
54
- const footerBackground = (0, _uiColorUtils.color2hex)(modalFooterStyle.getPropertyValue('background-color'));
55
- const footerBorderColor = (0, _uiColorUtils.color2hex)(modalFooterStyle.getPropertyValue('border-top-color'));
56
- expect(modalFooter).toBeInTheDocument();
57
- expect(footerBackground).toBe(themeVariables.inverseBackground);
58
- expect(footerBorderColor).toBe(themeVariables.inverseBorderColor);
59
- });
60
- });