amis-rpc-design/node_modules/node-abort-controller/__tests__/browser.js
2023-10-07 19:42:30 +08:00

20 lines
565 B
JavaScript

describe("AbortController in browser", function () {
// Mock AbortController
const mockedGlobalAbortController = jest.fn();
beforeAll(() => {
// Attach mocked AbortController to global
self.AbortController = mockedGlobalAbortController;
});
it("should call global abort controller", function () {
// Require module after global setup
const { AbortController } = require("../browser.js");
const controller = new AbortController();
expect(controller).toBeTruthy();
expect(mockedGlobalAbortController).toBeCalled();
});
});