MCPcopy Create free account
hub / github.com/middleapi/orpc / assertSuccessCase

Function assertSuccessCase

packages/client/src/adapters/fetch/rpc-link.test.ts:13–41  ·  view source on GitHub ↗
(value: unknown, expected: unknown)

Source from the content-addressed store, hash-verified

11describe.each(supportedDataTypes)('rpcLink: $name', ({ value, expected }) => {
12 describe.each(['GET', 'POST'] as const)('method: %s', (method) => {
13 async function assertSuccessCase(value: unknown, expected: unknown): Promise<true> {
14 const handler = vi.fn(({ input }) => input)
15
16 const rpcHandler = new RPCHandler(os.handler(handler), {
17 strictGetMethodPluginEnabled: false,
18 })
19
20 const rpcLink = new RPCLink({
21 url: 'http://api.example.com',
22 method,
23 fetch: async (request) => {
24 const { matched, response } = await rpcHandler.handle(request)
25
26 if (matched) {
27 return response
28 }
29
30 throw new Error('No procedure match')
31 },
32 })
33
34 const output = await rpcLink.call([], value, { context: {} })
35
36 expect(output).toEqual(expected)
37 expect(handler).toHaveBeenCalledTimes(1)
38 expect(handler).toHaveBeenCalledWith(expect.objectContaining({ input: expected }))
39
40 return true
41 }
42
43 async function assertErrorCase(value: unknown, expected: unknown): Promise<true> {
44 const handler = vi.fn(({ input }) => {

Callers 1

rpc-link.test.tsFile · 0.70

Calls 3

handlerMethod · 0.80
callMethod · 0.65
handleMethod · 0.45

Tested by

no test coverage detected