diff --git a/components/affix/__tests__/Affix.test.tsx b/components/affix/__tests__/Affix.test.tsx index cbe9b44815..80b22c4474 100644 --- a/components/affix/__tests__/Affix.test.tsx +++ b/components/affix/__tests__/Affix.test.tsx @@ -1,10 +1,9 @@ import type { CSSProperties } from 'react'; import React, { useEffect, useRef } from 'react'; -import type { InternalAffixClass } from '..'; import Affix from '..'; import accessibilityTest from '../../../tests/shared/accessibilityTest'; import rtlTest from '../../../tests/shared/rtlTest'; -import { render, triggerResize, waitFakeTimer } from '../../../tests/utils'; +import { render, waitFakeTimer } from '../../../tests/utils'; import Button from '../../button'; const events: Partial) => void>> = {}; @@ -14,11 +13,9 @@ interface AffixProps { offsetBottom?: number; style?: CSSProperties; onChange?: () => void; - onTestUpdatePosition?: () => void; - getInstance?: (inst: InternalAffixClass) => void; } -const AffixMounter: React.FC = ({ getInstance, ...restProps }) => { +const AffixMounter: React.FC = (props) => { const container = useRef(null); useEffect(() => { if (container.current) { @@ -31,8 +28,8 @@ const AffixMounter: React.FC = ({ getInstance, ...restProps }) => { }, []); return (
- container.current} {...restProps}> - + container.current} {...props}> +
); @@ -124,36 +121,6 @@ describe('Affix Render', () => { }); describe('updatePosition when target changed', () => { - it('function change', async () => { - document.body.innerHTML = '
'; - const container = document.getElementById('mounter'); - const getTarget = () => container; - let affixInstance: InternalAffixClass; - const { rerender } = render( - { - affixInstance = node as InternalAffixClass; - }} - target={getTarget} - > - {null} - , - ); - rerender( - { - affixInstance = node as InternalAffixClass; - }} - target={() => null} - > - {null} - , - ); - expect(affixInstance!.state.status).toBe(0); - expect(affixInstance!.state.affixStyle).toBe(undefined); - expect(affixInstance!.state.placeholderStyle).toBe(undefined); - }); - it('check position change before measure', async () => { const { container } = render( <> @@ -169,80 +136,5 @@ describe('Affix Render', () => { await movePlaceholder(1000); expect(container.querySelector('.ant-affix')).toBeTruthy(); }); - - it('do not measure when hidden', async () => { - let affixInstance: InternalAffixClass | null = null; - - const { rerender } = render( - { - affixInstance = inst; - }} - offsetBottom={0} - />, - ); - await waitFakeTimer(); - const firstAffixStyle = affixInstance!.state.affixStyle; - - rerender( - { - affixInstance = inst; - }} - offsetBottom={0} -