mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
test: add case for coverage (#38018)
This commit is contained in:
parent
71cfa31728
commit
82de4942d5
@ -5,7 +5,7 @@ import accessibilityTest from '../../../tests/shared/accessibilityTest';
|
||||
import rtlTest from '../../../tests/shared/rtlTest';
|
||||
import { render, triggerResize, waitFakeTimer } from '../../../tests/utils';
|
||||
import Button from '../../button';
|
||||
import { getObserverEntities } from '../utils';
|
||||
import { addObserveTarget, getObserverEntities } from '../utils';
|
||||
|
||||
const events: Partial<Record<keyof HTMLElementEventMap, (ev: Partial<Event>) => void>> = {};
|
||||
|
||||
@ -248,5 +248,11 @@ describe('Affix Render', () => {
|
||||
expect(updateCalled).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('addObserveTarget should not Throw Error when target is null', () => {
|
||||
expect(() => {
|
||||
addObserveTarget(null);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -51,8 +51,10 @@ export function getObserverEntities() {
|
||||
return observerEntities;
|
||||
}
|
||||
|
||||
export function addObserveTarget<T>(target: HTMLElement | Window | null, affix: T): void {
|
||||
if (!target) return;
|
||||
export function addObserveTarget<T>(target: HTMLElement | Window | null, affix?: T): void {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
let entity: ObserverEntity | undefined = observerEntities.find(item => item.target === target);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user