Skip to content

Commit

Permalink
chore(core): remove the isomorphic-unfetch dependency (#12023)
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF authored Sep 13, 2023
1 parent 31f1067 commit 1ff5bdf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
20 changes: 10 additions & 10 deletions packages/core/__tests__/clients/fetch.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
const mockUnfetch = jest.fn();
jest.mock('isomorphic-unfetch', () => {
global['fetch'] = mockUnfetch;
});

import { fetchTransferHandler } from '../../src/clients/handlers/fetch';

describe(fetchTransferHandler.name, () => {
Expand All @@ -25,17 +20,22 @@ describe(fetchTransferHandler.name, () => {
url: new URL('https://foo.bar'),
};
const mockPayloadValue = 'payload value';
const mockFetch = jest.fn();

beforeAll(() => {
global['fetch'] = mockFetch;
});

beforeEach(() => {
jest.clearAllMocks();
mockUnfetch.mockResolvedValue(mockFetchResponse);
mockFetch.mockResolvedValue(mockFetchResponse);
});

test('should support abort signal', async () => {
const signal = new AbortController().signal;
await fetchTransferHandler(mockRequest, { abortSignal: signal });
expect(mockUnfetch).toBeCalledTimes(1);
expect(mockUnfetch.mock.calls[0][1]).toEqual(
expect(mockFetch).toBeCalledTimes(1);
expect(mockFetch.mock.calls[0][1]).toEqual(
expect.objectContaining({ signal })
);
});
Expand Down Expand Up @@ -88,8 +88,8 @@ describe(fetchTransferHandler.name, () => {
{ ...mockRequest, method, body: 'Mock Body' },
{}
);
expect(mockUnfetch).toBeCalledTimes(1);
expect(mockUnfetch.mock.calls[0][0].body).toBeUndefined();
expect(mockFetch).toBeCalledTimes(1);
expect(mockFetch.mock.calls[0][0].body).toBeUndefined();
}
);
});
2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
"@aws-crypto/sha256-js": "5.0.0",
"@aws-sdk/types": "3.398.0",
"@smithy/util-hex-encoding": "2.0.0",
"@types/node-fetch": "2.6.4",
"isomorphic-unfetch": "^3.0.0",
"tslib": "^2.5.0",
"uuid": "^9.0.0",
"zen-observable-ts": "0.8.19",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/clients/handlers/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import 'isomorphic-unfetch'; // TODO: remove this dependency in v6
import { HttpRequest, HttpResponse, HttpTransferOptions } from '../types/http';
import { TransferHandler } from '../types/core';
import { withMemoization } from '../utils/memoization';
Expand Down
30 changes: 0 additions & 30 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1ff5bdf

Please sign in to comment.