mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
test: Optimize test cases (#39414)
This commit is contained in:
parent
7e821bc8f6
commit
d684b52abf
@ -17,7 +17,11 @@ exports[`Watermark MutationObserver should work properly 1`] = `
|
||||
<div
|
||||
class="watermark"
|
||||
style="position: relative;"
|
||||
/>
|
||||
>
|
||||
<div
|
||||
style="z-index: 9; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-size: 216px; pointer-events: none; background-repeat: repeat; background-position: 0px 0px; background-image: url('data:image/png;base64,00');"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -28,7 +32,7 @@ exports[`Watermark Observe the modification of style 1`] = `
|
||||
style="position: relative;"
|
||||
>
|
||||
<div
|
||||
style=""
|
||||
style="z-index: 9; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-size: 216px; pointer-events: none; background-repeat: repeat; background-position: -300px -300px; background-image: url('data:image/png;base64,00');"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import Watermark from '..';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
import rtlTest from '../../../tests/shared/rtlTest';
|
||||
import { render } from '../../../tests/utils';
|
||||
import { render, waitFor } from '../../../tests/utils';
|
||||
|
||||
describe('Watermark', () => {
|
||||
mountTest(Watermark);
|
||||
@ -49,19 +49,21 @@ describe('Watermark', () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('MutationObserver should work properly', () => {
|
||||
it('MutationObserver should work properly', async () => {
|
||||
const { container } = render(<Watermark className="watermark" content="MutationObserver" />);
|
||||
const target = container.querySelector<HTMLDivElement>('.watermark div');
|
||||
target?.remove();
|
||||
await waitFor(() => expect(target).toBeTruthy());
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Observe the modification of style', () => {
|
||||
it('Observe the modification of style', async () => {
|
||||
const { container } = render(
|
||||
<Watermark offset={[-200, -200]} className="watermark" content="MutationObserver" />,
|
||||
);
|
||||
const target = container.querySelector<HTMLDivElement>('.watermark div');
|
||||
target?.setAttribute('style', '');
|
||||
await waitFor(() => expect(target).toBeTruthy());
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user