Skip to content

Commit

Permalink
Merge branch 'main' into fix/react-native-events
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Nov 16, 2023
2 parents 4ab3ccf + 75bbb96 commit db8facb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/handlers/GraphQLHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type GraphQLResolverExtras<Variables extends GraphQLVariables> = {
query: string
operationName: string
variables: Variables
cookies: Record<string, string | Array<string>>
cookies: Record<string, string>
}

export type GraphQLRequestBody<VariablesType extends GraphQLVariables> =
Expand Down
2 changes: 1 addition & 1 deletion src/core/handlers/HttpHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type HttpRequestParsedResult = {

export type HttpRequestResolverExtras<Params extends PathParams> = {
params: Params
cookies: Record<string, string | Array<string>>
cookies: Record<string, string>
}

/**
Expand Down
38 changes: 38 additions & 0 deletions test/node/rest-api/request/body/body-protobuf.node.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// @vitest-environment node
import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'

const server = setupServer(
http.post('https://example.com/protobuf', async ({ request }) => {
const buffer = await request.arrayBuffer()

return new HttpResponse(new Uint8Array(buffer), {
headers: {
'Content-Type': 'application/protobuf',
},
})
}),
)

beforeAll(() => {
server.listen()
})

afterAll(() => {
server.close()
})

it('responds with a "application/protobuf" mocked response', async () => {
const payload = new Uint8Array([138, 1, 6, 10, 4, 10, 2, 32, 1])

const response = await fetch('https://example.com/protobuf', {
method: 'POST',
headers: {
'Content-Type': 'application/protobuf',
},
body: payload,
})
const body = await response.arrayBuffer()

expect(new Uint8Array(body)).toEqual(payload)
})

0 comments on commit db8facb

Please sign in to comment.