From 961cbc6312b4a5b7e245a48980ff225a0ee11582 Mon Sep 17 00:00:00 2001 From: Jayden Seric <me@jaydenseric.com> Date: Sun, 22 Oct 2023 18:02:30 +1100 Subject: [PATCH] Fix tests broken by `@apollo/client` v3.7.0. --- changelog.md | 1 + createUploadLink.test.mjs | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index 65b4b74..4864635 100644 --- a/changelog.md +++ b/changelog.md @@ -60,6 +60,7 @@ - Updated `actions/checkout` to v3. - Updated `actions/setup-node` to v3. - Reorganized the test file structure. +- In tests, for objects with the property `headers` that as of [`@apollo/client`](https://npm.im/@apollo/client) [v3.7.0](https://github.com/apollographql/apollo-client/releases/tag/v3.7.0) is a null-prototype object, use the assertion `deepEqual` instead of `deepStrictEqual`. ## 17.0.0 diff --git a/createUploadLink.test.mjs b/createUploadLink.test.mjs index ed9a3e4..122108c 100644 --- a/createUploadLink.test.mjs +++ b/createUploadLink.test.mjs @@ -2,7 +2,7 @@ import { ApolloLink } from "@apollo/client/link/core/ApolloLink.js"; import { concat } from "@apollo/client/link/core/concat.js"; import { execute } from "@apollo/client/link/core/execute.js"; import { AbortController, AbortSignal } from "abort-controller"; -import { deepStrictEqual, strictEqual } from "assert"; +import { deepEqual, deepStrictEqual, strictEqual } from "assert"; import { File, FormData } from "formdata-node"; import gql from "graphql-tag"; import { AbortError, Response } from "node-fetch"; @@ -75,7 +75,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ variables: {}, query }), @@ -162,7 +162,7 @@ export default (tests) => { strictEqual(formDataEntries[2][1] instanceof File, true); strictEqual(formDataEntries[2][1].name, fileName); strictEqual(formDataEntries[2][1].type, fileType); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*" }, }); @@ -222,7 +222,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ variables: {}, query }), @@ -284,7 +284,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ @@ -351,7 +351,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "GET", headers: { accept: "*/*", "content-type": "application/json" }, }); @@ -412,7 +412,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "GET", headers: { accept: "*/*", "content-type": "application/json" }, }); @@ -501,7 +501,7 @@ export default (tests) => { strictEqual(formDataEntries[2][1] instanceof File, true); strictEqual(formDataEntries[2][1].name, fileName); strictEqual(formDataEntries[2][1].type, fileType); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*" }, }); @@ -617,7 +617,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ variables: {}, query }), @@ -680,7 +680,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", @@ -757,7 +757,7 @@ export default (tests) => { if (global.AbortSignal) strictEqual(fetchOptionsSignal instanceof global.AbortSignal, true); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*", @@ -864,7 +864,7 @@ export default (tests) => { strictEqual(formDataEntries[2][1] instanceof File, true); strictEqual(formDataEntries[2][1].name, fileName); strictEqual(formDataEntries[2][1].type, fileType); - deepStrictEqual(fetchOptionsRest, { + deepEqual(fetchOptionsRest, { method: "POST", headers: { accept: "*/*" }, }); @@ -1052,7 +1052,7 @@ export default (tests) => { const observerError = await observerErrorPromise; strictEqual(fetchUri, defaultUri); - deepStrictEqual(fetchOptions, { + deepEqual(fetchOptions, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ variables: {}, query }), @@ -1118,7 +1118,7 @@ export default (tests) => { const observerError = await observerErrorPromise; strictEqual(fetchUri, defaultUri); - deepStrictEqual(fetchOptions, { + deepEqual(fetchOptions, { method: "POST", headers: { accept: "*/*", "content-type": "application/json" }, body: JSON.stringify({ variables: {}, query }),