test: Fix test case

This commit is contained in:
二货机器人 2022-09-07 10:55:07 +08:00
parent 1cad665d15
commit f3a26d170f

View File

@ -110,33 +110,37 @@ describe('Tag', () => {
describe('visibility', () => { describe('visibility', () => {
it('can be controlled by visible with visible as initial value', () => { it('can be controlled by visible with visible as initial value', () => {
const { asFragment, rerender } = render(<Tag visible />); const { container, rerender } = render(<Tag visible />);
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeFalsy();
rerender(<Tag visible={false} />); rerender(<Tag visible={false} />);
act(() => { act(() => {
jest.runAllTimers(); jest.runAllTimers();
}); });
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeTruthy();
rerender(<Tag visible />); rerender(<Tag visible />);
act(() => { act(() => {
jest.runAllTimers(); jest.runAllTimers();
}); });
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeFalsy();
}); });
it('can be controlled by visible with hidden as initial value', () => { it('can be controlled by visible with hidden as initial value', () => {
const { asFragment, rerender } = render(<Tag visible={false} />); const { container, rerender } = render(<Tag visible={false} />);
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeTruthy();
rerender(<Tag visible />); rerender(<Tag visible />);
act(() => { act(() => {
jest.runAllTimers(); jest.runAllTimers();
}); });
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeFalsy();
rerender(<Tag visible={false} />); rerender(<Tag visible={false} />);
act(() => { act(() => {
jest.runAllTimers(); jest.runAllTimers();
}); });
expect(asFragment().firstChild).toMatchSnapshot(); expect(container.querySelector('.ant-tag-hidden')).toBeTruthy();
}); });
}); });