pref: call setProps rathor than componentDidUpdate

This commit is contained in:
zy410419243 2019-03-09 16:36:30 +08:00
parent 64b6197441
commit cc8d8b05aa

View File

@ -131,10 +131,10 @@ describe('Affix Render', () => {
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);
wrapper = mount(<Affix target={getTarget} />);
wrapper.setProps({ target: null });
expect(wrapper.instance().state.status).toBe(0);
expect(wrapper.instance().state.affixStyle).toBe(undefined);
expect(wrapper.instance().state.placeholderStyle).toBe(undefined);
});
});