ant-design/components/_util/__tests__/responsiveObserve.test.js
zhangchen 26fa36083e
fix: ResponsiveObserve unsubscribe (#25309) (#25319)
* fix: ResponsiveObserve unsubscribe (#25309)

* fix: ResponsiveObserve unsubscribe (#25309)

* fix: ResponsiveObserve unsubscribe

* test: add responsiveObserve.test.js
2020-07-02 10:46:47 +08:00

15 lines
569 B
JavaScript

import ResponsiveObserve, { responsiveMap } from '../responsiveObserve';
describe('Test ResponsiveObserve', () => {
it('test ResponsiveObserve subscribe and unsubscribe', () => {
const { xs } = responsiveMap;
const subscribeFunc = jest.fn();
const token = ResponsiveObserve.subscribe(subscribeFunc);
expect(ResponsiveObserve.matchHandlers[xs].mql.matches).toBeTruthy();
expect(subscribeFunc).toBeCalledTimes(1);
ResponsiveObserve.unsubscribe(token);
expect(ResponsiveObserve.matchHandlers[xs].mql.removeListener).toBeCalled();
});
});