|
1 | 1 | import { cleanup, fireEvent, render, act } from '@testing-library/react';
|
2 | 2 | import KeyCode from 'rc-util/lib/KeyCode';
|
| 3 | +import { resetWarned } from 'rc-util/lib/warning'; |
3 | 4 | import React from 'react';
|
4 | 5 | import type { DrawerProps } from '../src';
|
5 | 6 | import Drawer from '../src';
|
@@ -34,7 +35,9 @@ describe('rc-drawer-menu', () => {
|
34 | 35 | act(() => {
|
35 | 36 | jest.runAllTimers();
|
36 | 37 | });
|
37 |
| - expect(document.querySelector('.rc-drawer-content-hidden')).toBeTruthy(); |
| 38 | + expect( |
| 39 | + document.querySelector('.rc-drawer-content-wrapper-hidden'), |
| 40 | + ).toBeTruthy(); |
38 | 41 | });
|
39 | 42 |
|
40 | 43 | describe('push', () => {
|
@@ -311,12 +314,34 @@ describe('rc-drawer-menu', () => {
|
311 | 314 | });
|
312 | 315 |
|
313 | 316 | it('width on the correct element', () => {
|
| 317 | + resetWarned(); |
| 318 | + const errSpy = jest.spyOn(console, 'error'); |
314 | 319 | const { container } = render(
|
315 | 320 | <Drawer width="93%" open getContainer={false} />,
|
316 | 321 | );
|
317 | 322 |
|
318 | 323 | expect(container.querySelector('.rc-drawer-content-wrapper')).toHaveStyle({
|
319 | 324 | width: '93%',
|
320 | 325 | });
|
| 326 | + |
| 327 | + expect(errSpy).not.toHaveBeenCalled(); |
| 328 | + errSpy.mockRestore(); |
| 329 | + }); |
| 330 | + |
| 331 | + it('warning for string width', () => { |
| 332 | + resetWarned(); |
| 333 | + const errSpy = jest.spyOn(console, 'error'); |
| 334 | + const { container } = render( |
| 335 | + <Drawer width="93" open getContainer={false} />, |
| 336 | + ); |
| 337 | + |
| 338 | + expect(container.querySelector('.rc-drawer-content-wrapper')).toHaveStyle({ |
| 339 | + width: '93px', |
| 340 | + }); |
| 341 | + |
| 342 | + expect(errSpy).toHaveBeenCalledWith( |
| 343 | + 'Warning: Invalid value type of `width` or `height` which should be number type instead.', |
| 344 | + ); |
| 345 | + errSpy.mockRestore(); |
321 | 346 | });
|
322 | 347 | });
|
0 commit comments