Skip to content

Commit

Permalink
add test for call with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Mar 6, 2024
1 parent 3034234 commit d06e3c2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/client-react-streaming/src/registerApolloClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,28 @@ it("calling `getClient` twice during different React renders will return differe
assert.ok(clients[0] instanceof ApolloClient);
assert.notStrictEqual(clients[0], clients[1]);
});

it("calling `getClient` with parameters results in an error", async () => {
const { getClient } = registerApolloClient(makeClient);

function App() {
// @ts-expect-error yeah this is a bad idea, that's why we do it in a test
getClient("argument");
return <div></div>;
}

let error: undefined | Error;
const stream = renderToPipeableStream(
React.createElement(App),
{},
{
onError(e) {
error = e;
},
}
);
await drain(stream);
assert.ok(
/You cannot pass arguments into `getClient`./.test(error?.message || "")
);
});

0 comments on commit d06e3c2

Please sign in to comment.