Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal(fix): Update fetch polyfill for tests and fix some tests #553

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -62,7 +62,7 @@
"jest": "^26.6.3",
"lerna": "^4.0.0",
"mkdirp": "^1.0.4",
"nock": "^13.0.6",
"nock": "^13.1.0",
"prettier": "^2.2.1",
"react": "^18.0.0-0",
"react-dom": "^18.0.0-0",
Expand All @@ -81,7 +81,7 @@
"ts-node": "^9.1.1",
"ttypescript": "^1.5.12",
"typescript": "^4.1.3",
"whatwg-fetch": "3.0.0"
"whatwg-fetch": "3.6.2"
},
"resolutions": {
"@lerna/conventional-commits": "https://github.com/ntucker/lerna-conventional-commits.git"
Expand Down
Expand Up @@ -810,7 +810,7 @@ for (const makeProvider of [makeCacheProvider, makeExternalCacheProvider]) {
}),
);

// second optimistic
// third optimistic
mynock
.patch('/article-cooler/5')
.delay(500)
Expand Down
4 changes: 2 additions & 2 deletions packages/endpoint/src/__tests__/endpoint.ts
Expand Up @@ -586,10 +586,10 @@ describe('Endpoint', () => {
expect(user.username).toBe(payload.username);
});

it('should reject when aborted', () => {
it('should reject when aborted', async () => {
const abort = new AbortController();
const AbortUser = UserDetail.extend({ signal: abort.signal });
expect(async () => {
await expect(async () => {
const promise = AbortUser({ id: payload.id });
abort.abort();
return await promise;
Expand Down
6 changes: 5 additions & 1 deletion packages/hooks/src/__tests__/useCancelling.ts
Expand Up @@ -34,6 +34,10 @@ describe('useCancelling()', () => {
.delay(2000)
.reply(200, payload2);
});
afterAll(() => {
jest.useRealTimers();
nock.cleanAll();
});

it('should abort when props change and resolve when kept the same', async () => {
const { result, rerender } = renderHook(
Expand All @@ -50,7 +54,7 @@ describe('useCancelling()', () => {
expect(ogPromise).rejects.toMatchInlineSnapshot(`[AbortError: Aborted]`);
const nextPromise = result.current({ id: '7' });
jest.advanceTimersByTime(2000);
await expect(nextPromise).resolves.toMatchInlineSnapshot(`
expect(nextPromise).resolves.toMatchInlineSnapshot(`
Object {
"id": "7",
"title": "second one",
Expand Down
9 changes: 7 additions & 2 deletions yarn.lock
Expand Up @@ -8680,7 +8680,7 @@ nocache@^2.1.0:
resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f"
integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==

nock@^13.0.6:
nock@^13.1.0:
version "13.1.0"
resolved "https://registry.yarnpkg.com/nock/-/nock-13.1.0.tgz#41c8ce8b35ab7d618c4cbf40de1d5bce319979ba"
integrity sha512-3N3DUY8XYrxxzWazQ+nSBpiaJ3q6gcpNh4gXovC/QBxrsvNp4tq+wsLHF6mJ3nrn3lPLn7KCJqKxy/9aD+0fdw==
Expand Down Expand Up @@ -11996,7 +11996,12 @@ whatwg-encoding@^1.0.5:
dependencies:
iconv-lite "0.4.24"

whatwg-fetch@3.0.0, whatwg-fetch@^3.0.0:
whatwg-fetch@3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==

whatwg-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==
Expand Down