Skip to content

Commit

Permalink
additional adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 5, 2024
1 parent 83a35d8 commit 67a6a42
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 708 deletions.
10 changes: 7 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.tabSize": 2,
"editor.rulers": [80],
"editor.rulers": [
80
],
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.enableFiletypes": ["mdx"],
"jest.jestCommandLine": "node_modules/.bin/jest --config ./config/jest.config.js --ignoreProjects 'ReactDOM 17' --runInBand"
"cSpell.enableFiletypes": [
"mdx"
],
"jest.jestCommandLine": "node --expose-gc node_modules/.bin/jest --config ./config/jest.config.js --ignoreProjects 'ReactDOM 17' --runInBand"
}
80 changes: 38 additions & 42 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ describe("client", () => {
});

expect(() => {
client.query(
void client.query(
gql`
{
a
}
` as any
);
}).toThrowError(
}).toThrow(
"query option is required. You must specify your GraphQL document in the query option."
);
expect(() => {
client.query({ query: "{ a }" } as any);
}).toThrowError('You must wrap the query string in a "gql" tag.');
void client.query({ query: "{ a }" } as any);
}).toThrow('You must wrap the query string in a "gql" tag.');
});

it("should throw an error if mutation option is missing", async () => {
Expand Down Expand Up @@ -137,48 +137,44 @@ describe("client", () => {
}
);

itAsync(
"should allow a single query with an apollo-link enabled network interface",
(resolve, reject) => {
const query = gql`
query people {
allPeople(first: 1) {
people {
name
__typename
}
it("should allow a single query with an apollo-link enabled network interface", async () => {
const query = gql`
query people {
allPeople(first: 1) {
people {
name
__typename
}
__typename
}
`;
}
`;

const data = {
allPeople: {
people: [
{
name: "Luke Skywalker",
__typename: "Person",
},
],
__typename: "People",
},
};
const data = {
allPeople: {
people: [
{
name: "Luke Skywalker",
__typename: "Person",
},
],
__typename: "People",
},
};

const variables = { first: 1 };
const variables = { first: 1 };

const link = ApolloLink.from([() => Observable.of({ data })]);
const link = ApolloLink.from([() => Observable.of({ data })]);

const client = new ApolloClient({
link,
cache: new InMemoryCache({ addTypename: false }),
});
const client = new ApolloClient({
link,
cache: new InMemoryCache({ addTypename: false }),
});

client.query({ query, variables }).then((actualResult) => {
expect(actualResult.data).toEqual(data);
resolve();
});
}
);
const actualResult = await client.query({ query, variables });

expect(actualResult.data).toEqual(data);
});

itAsync(
"should allow for a single query with complex default variables to take place",
Expand Down Expand Up @@ -1767,7 +1763,7 @@ describe("client", () => {
cache: new InMemoryCache(),
});
expect(() => {
client.query({ query, returnPartialData: true } as QueryOptions);
void client.query({ query, returnPartialData: true } as QueryOptions);
}).toThrowError(/returnPartialData/);
});

Expand All @@ -1777,7 +1773,7 @@ describe("client", () => {
cache: new InMemoryCache(),
});
expect(() => {
client.query({ query, returnPartialData: true } as QueryOptions);
void client.query({ query, returnPartialData: true } as QueryOptions);
}).toThrowError(/returnPartialData/);
});
});
Expand Down Expand Up @@ -2072,7 +2068,7 @@ describe("client", () => {
// this write should be completely ignored by the standby query
client.writeQuery({ query, data: data2 });
setTimeout(() => {
obs.setOptions({ query, fetchPolicy: "cache-first" });
void obs.setOptions({ query, fetchPolicy: "cache-first" });
}, 10);

await expect(stream).toEmitMatchedValue({ data: data2 });
Expand Down Expand Up @@ -3653,7 +3649,7 @@ describe("@connection", () => {
// Refetching makes a copy of the current options, which
// includes options.nextFetchPolicy, so the inner
// nextFetchPolicy function ends up getting called twice.
obs.refetch();
void obs.refetch();

await expect(stream).toEmitMatchedValue({ data: { count: "initial" } });
expect(nextFetchPolicyCallCount).toBe(2);
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ describe("fetchMore on an observable query with connection", () => {
expect(data.entry.comments.length).toBe(10);
}

observable.fetchMore({
void observable.fetchMore({
variables: { start: 10 },
updateQuery: (prev: any, options: any) => {
const state = cloneDeep(prev) as any;
Expand Down Expand Up @@ -1767,7 +1767,7 @@ describe("fetchMore on an observable query with connection", () => {
expect((data as any).entry.comments.length).toBe(10);
}

observable.fetchMore({
void observable.fetchMore({
variables: { start: 10 },
});

Expand Down
Loading

0 comments on commit 67a6a42

Please sign in to comment.