Skip to content

Commit

Permalink
🧹 chore: chore
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Sep 20, 2023
1 parent 59df93e commit fd6524d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { expect } from 'bun:test'
import { t, Elysia, RouteSchema } from '../../src'
import { t, Elysia, RouteSchema, Cookie } from '../../src'
import { expectTypeOf } from 'expect-type'

const app = new Elysia()
Expand Down Expand Up @@ -32,7 +32,7 @@ app.model({
})
}).get(
'/',
({ headers, query, params, body }) => {
({ headers, query, params, body, cookie }) => {
// ? unwrap body type
expectTypeOf<{
username: string
Expand All @@ -57,14 +57,23 @@ app.model({
password: string
}>().toEqualTypeOf<typeof headers>()

// ? unwrap cookie
expectTypeOf<
Record<string, Cookie<any>> & {
username: Cookie<string>
password: Cookie<string>
}
>().toEqualTypeOf<typeof cookie>()

return body
},
{
body: 't',
params: 't',
query: 't',
headers: 't',
response: 't'
response: 't',
cookie: 't'
}
)

Expand Down

0 comments on commit fd6524d

Please # to comment.