Skip to content

Commit

Permalink
Merge pull request #266 from apollographql/pr/test-changes
Browse files Browse the repository at this point in the history
try to stabilize flimsy tests
  • Loading branch information
phryneas authored Apr 2, 2024
2 parents b508a5a + a4e1984 commit 9fc65d3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: "20.11.0"
cache: "yarn"
- run: yarn install --immutable
- run: yarn workspaces foreach --all --include "@apollo/*" add -D -P @apollo/client@${{ matrix.version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import { test, mock } from "node:test";
import assert from "node:assert";
import { fromPartial } from "@total-typescript/shoehorn";
import type { SubscriptionObserver } from "zen-observable-ts";
import { runInConditions } from "./util/runInConditions.js";

runInConditions("node", "browser");

const { DebounceMultipartResponsesLink: AccumulateMultipartResponsesLink } =
await import("#bundled");

test("normal queries can resolve synchronously", () => {
await test("normal queries can resolve synchronously", () => {
const query = gql`
query {
fastField
Expand Down Expand Up @@ -49,7 +46,7 @@ test("normal queries can resolve synchronously", () => {
});
});

test("deferred query will complete synchonously if maxDelay is 0", () => {
await test("deferred query will complete synchonously if maxDelay is 0", () => {
const query = gql`
query {
fastField
Expand Down Expand Up @@ -84,7 +81,7 @@ test("deferred query will complete synchonously if maxDelay is 0", () => {
});
});

test("`next` call will be debounced and results will be merged together", () => {
await test("`next` call will be debounced and results will be merged together", () => {
mock.timers.enable();

const query = gql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { gql, Observable } from "@apollo/client/core/index.js";
import { print } from "graphql";
import { it } from "node:test";
import assert from "node:assert";
import { runInConditions } from "./util/runInConditions.js";

runInConditions("node", "browser");

const { RemoveMultipartDirectivesLink } = await import("#bundled");

Expand Down Expand Up @@ -51,7 +48,7 @@ const queryWithDeferAndStripAnnotation = gql`
}
`;

it("removes fields with a @defer directive", () => {
await it("removes fields with a @defer directive", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -69,7 +66,7 @@ query myQuery {
);
});

it("`stripDefer` defaults to `true`", () => {
await it("`stripDefer` defaults to `true`", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -87,7 +84,7 @@ query myQuery {
);
});

it("preserves @defer fields with a `SsrDontStrip` label", () => {
await it("preserves @defer fields with a `SsrDontStrip` label", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: true,
});
Expand All @@ -114,7 +111,7 @@ query myQuery {
);
});

it("can be configured to not remove @defer fields", () => {
await it("can be configured to not remove @defer fields", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: false,
});
Expand All @@ -138,7 +135,7 @@ query myQuery {
);
});

it("even with `stripDefer: false`, certain fields can be marked for stripping", () => {
await it("even with `stripDefer: false`, certain fields can be marked for stripping", () => {
const link = new RemoveMultipartDirectivesLink({
stripDefer: false,
});
Expand Down

0 comments on commit 9fc65d3

Please sign in to comment.