From d06e3c231aab786c8a18d64dfdcffc9761e617ea Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Fri, 1 Mar 2024 17:44:20 +0100 Subject: [PATCH] add test for call with parameters --- .../src/registerApolloClient.test.tsx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/client-react-streaming/src/registerApolloClient.test.tsx b/packages/client-react-streaming/src/registerApolloClient.test.tsx index f94e3b63..37e834e6 100644 --- a/packages/client-react-streaming/src/registerApolloClient.test.tsx +++ b/packages/client-react-streaming/src/registerApolloClient.test.tsx @@ -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
; + } + + 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 || "") + ); +});