mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 22:39:34 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
19 lines
790 B
TypeScript
19 lines
790 B
TypeScript
import React from 'react';
|
|
|
|
import { render } from '../../../tests/utils';
|
|
import useSize from '../hooks/useSize';
|
|
|
|
describe('useSize', () => {
|
|
it('useSize', () => {
|
|
const Demo: React.FC<{ size?: any }> = ({ size }) => <div>{useSize(size)}</div>;
|
|
const { container, rerender } = render(<Demo />);
|
|
expect(container.querySelector<HTMLDivElement>('div')?.textContent).toBe('');
|
|
rerender(<Demo size="test-size1" />);
|
|
expect(container.querySelector<HTMLDivElement>('div')?.textContent).toBe('test-size1');
|
|
rerender(<Demo size={() => 'test-size2'} />);
|
|
expect(container.querySelector<HTMLDivElement>('div')?.textContent).toBe('test-size2');
|
|
rerender(<Demo size={1} />);
|
|
expect(container.querySelector<HTMLDivElement>('div')?.textContent).toBe('');
|
|
});
|
|
});
|