Skip to content

Commit

Permalink
internal(fix): Update fetch polyfill for tests and fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Mar 1, 2021
1 parent 02540ac commit d37b5b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -56,7 +56,7 @@
"ignore-styles": "^5.0.1",
"jest": "^26.6.3",
"lerna": "^3.22.1",
"nock": "^13.0.6",
"nock": "^13.0.7",
"prettier": "^2.2.1",
"react": "17.0.1",
"react-dom": "17.0.1",
Expand All @@ -76,7 +76,7 @@
"ts-node": "^9.1.1",
"ttypescript": "^1.5.12",
"typescript": "^4.1.3",
"whatwg-fetch": "3.0.0"
"whatwg-fetch": "3.6.1"
},
"resolutions": {
"@lerna/conventional-commits": "https://github.com/ntucker/lerna-conventional-commits.git"
Expand Down
Expand Up @@ -664,7 +664,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 @@ -418,10 +418,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
15 changes: 10 additions & 5 deletions yarn.lock
Expand Up @@ -9912,10 +9912,10 @@ 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:
version "13.0.9"
resolved "https://registry.yarnpkg.com/nock/-/nock-13.0.9.tgz#32b9f6408a71991b25f044109cac92ee556c8539"
integrity sha512-SoGx/J0SsZPOdBFrBC9PP6NwaEgOBQIRPbsOsO9q+OwOPWc5eT6wALSxn3ZNE4Fv2ImIUXM4Hv/07rjq/uWDew==
nock@^13.0.7:
version "13.0.7"
resolved "https://registry.yarnpkg.com/nock/-/nock-13.0.7.tgz#9bc718c66bd0862dfa14601a9ba678a406127910"
integrity sha512-WBz73VYIjdbO6BwmXODRQLtn7B5tldA9pNpWJe5QTtTEscQlY5KXU4srnGzBOK2fWakkXj69gfTnXGzmrsaRWw==
dependencies:
debug "^4.1.0"
json-stringify-safe "^5.0.1"
Expand Down Expand Up @@ -13650,7 +13650,12 @@ whatwg-encoding@^1.0.5:
dependencies:
iconv-lite "0.4.24"

whatwg-fetch@3.0.0, whatwg-fetch@>=0.10.0, whatwg-fetch@^3.0.0:
whatwg-fetch@3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.1.tgz#93bc4005af6c2cc30ba3e42ec3125947c8f54ed3"
integrity sha512-IEmN/ZfmMw6G1hgZpVd0LuZXOQDisrMOZrzYd5x3RAK4bMPlJohKUZWZ9t/QsTvH0dV9TbPDcc2OSuIDcihnHA==

whatwg-fetch@>=0.10.0, 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

0 comments on commit d37b5b9

Please sign in to comment.