* fix: ResponsiveObserve unsubscribe (#25309) * fix: ResponsiveObserve unsubscribe (#25309) * fix: ResponsiveObserve unsubscribe * test: add responsiveObserve.test.jspull/25377/head
parent
e3982e94f8
commit
26fa36083e
@ -0,0 +1,14 @@
|
||||
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();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue