mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
test: add test coverage (#37993)
* test: add test coverage * fix: fix * test: del test * fix: fix * fix: fix * chore: update test * chore: code clean * chore: code clean * test: update test case Co-authored-by: MadCcc <1075746765@qq.com>
This commit is contained in:
parent
82de4942d5
commit
2ef701be75
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import type { AffixProps, InternalAffixClass } from '..';
|
||||
import type { InternalAffixClass } from '..';
|
||||
import Affix from '..';
|
||||
import accessibilityTest from '../../../tests/shared/accessibilityTest';
|
||||
import rtlTest from '../../../tests/shared/rtlTest';
|
||||
@ -120,9 +120,8 @@ describe('Affix Render', () => {
|
||||
});
|
||||
|
||||
it('Anchor correct render when target is null', async () => {
|
||||
expect(() => {
|
||||
render(<Affix target={null as unknown as AffixProps['target']}>test</Affix>);
|
||||
}).not.toThrow();
|
||||
render(<Affix target={() => null}>test</Affix>);
|
||||
await waitFakeTimer();
|
||||
});
|
||||
|
||||
it('support offsetBottom', async () => {
|
||||
@ -202,6 +201,21 @@ describe('Affix Render', () => {
|
||||
expect(getObserverEntities()).toHaveLength(1);
|
||||
expect(getObserverEntities()[0].target).toBe(window);
|
||||
});
|
||||
it('check position change before measure', async () => {
|
||||
const { container } = render(
|
||||
<>
|
||||
<Affix offsetTop={10}>
|
||||
<Button>top</Button>
|
||||
</Affix>
|
||||
<Affix offsetBottom={10}>
|
||||
<Button>bottom</Button>
|
||||
</Affix>
|
||||
</>,
|
||||
);
|
||||
await waitFakeTimer();
|
||||
await movePlaceholder(1000);
|
||||
expect(container.querySelector('.ant-affix')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('updatePosition when size changed', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user