browser.js 565 B

12345678910111213141516171819
  1. describe("AbortController in browser", function () {
  2. // Mock AbortController
  3. const mockedGlobalAbortController = jest.fn();
  4. beforeAll(() => {
  5. // Attach mocked AbortController to global
  6. self.AbortController = mockedGlobalAbortController;
  7. });
  8. it("should call global abort controller", function () {
  9. // Require module after global setup
  10. const { AbortController } = require("../browser.js");
  11. const controller = new AbortController();
  12. expect(controller).toBeTruthy();
  13. expect(mockedGlobalAbortController).toBeCalled();
  14. });
  15. });