diff --git a/components/affix/__tests__/Affix.test.js b/components/affix/__tests__/Affix.test.js index 08ddc06711..520de6fda3 100644 --- a/components/affix/__tests__/Affix.test.js +++ b/components/affix/__tests__/Affix.test.js @@ -48,7 +48,8 @@ describe('Affix Render', () => { }; const originGetBoundingClientRect = HTMLElement.prototype.getBoundingClientRect; - HTMLElement.prototype.getBoundingClientRect = function getBoundingClientRect() { + // eslint-disable-next-line + HTMLElement.prototype.getBoundingClientRect = function() { return ( classRect[this.className] || { top: 0, @@ -127,4 +128,14 @@ describe('Affix Render', () => { jest.runAllTimers(); expect(wrapper.instance().affix.state.affixStyle.top).toBe(10); }); + + it('updatePosition when target changed', () => { + const container = '
'; + const getTarget = () => container; + wrapper = mount().instance(); + wrapper.componentDidUpdate({ target: null }); + expect(wrapper.state.status).toBe(0); + expect(wrapper.state.affixStyle).toBe(undefined); + expect(wrapper.state.placeholderStyle).toBe(undefined); + }); });