processInitQueue.spec.tsx 893 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import {processInitQueue} from 'sentry/bootstrap/processInitQueue';
  2. describe('processInitQueue', function () {
  3. it('processes queued up items', function () {
  4. const mock = jest.fn();
  5. const init = {
  6. name: 'onReady',
  7. onReady: mock,
  8. } as const;
  9. window.__onSentryInit = [init];
  10. processInitQueue();
  11. expect(mock).toHaveBeenCalledTimes(1);
  12. processInitQueue();
  13. expect(mock).toHaveBeenCalledTimes(1);
  14. window.__onSentryInit.push(init);
  15. expect(mock).toHaveBeenCalledTimes(2);
  16. });
  17. it('is called after `processInitQueue` has already run', function () {
  18. processInitQueue();
  19. const mock = jest.fn();
  20. const init = {
  21. name: 'onReady',
  22. onReady: mock,
  23. } as const;
  24. window.__onSentryInit.push(init);
  25. expect(mock).toHaveBeenCalledTimes(1);
  26. processInitQueue();
  27. expect(mock).toHaveBeenCalledTimes(1);
  28. });
  29. });