traceTreeEventDispatcher.spec.tsx 765 B

123456789101112131415161718192021
  1. import {TraceTreeEventDispatcher} from './traceTreeEventDispatcher';
  2. describe('TraceEventDispatcher', () => {
  3. it('dispatch events', () => {
  4. const dispatcher = new TraceTreeEventDispatcher();
  5. const mockCallback = jest.fn();
  6. dispatcher.on('trace timeline change', mockCallback);
  7. dispatcher.dispatch('trace timeline change', [0, 1]);
  8. expect(mockCallback).toHaveBeenCalledWith([0, 1]);
  9. });
  10. it('off events', () => {
  11. const dispatcher = new TraceTreeEventDispatcher();
  12. const mockCallback = jest.fn();
  13. dispatcher.on('trace timeline change', mockCallback);
  14. dispatcher.off('trace timeline change', mockCallback);
  15. dispatcher.dispatch('trace timeline change', [0, 1]);
  16. expect(mockCallback).not.toHaveBeenCalled();
  17. });
  18. });