mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
test: update cases for Affix
This commit is contained in:
parent
c289be6a8a
commit
a5016a2a1f
@ -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 = '<div id="mounter" />';
|
||||
const getTarget = () => container;
|
||||
wrapper = mount(<Affix target={getTarget} />).instance();
|
||||
wrapper.componentDidUpdate({ target: null });
|
||||
expect(wrapper.state.status).toBe(0);
|
||||
expect(wrapper.state.affixStyle).toBe(undefined);
|
||||
expect(wrapper.state.placeholderStyle).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user