Skip to content

Commit

Permalink
Add cookies property to the InjectOptions interface type definition (#74
Browse files Browse the repository at this point in the history
)

* Add cookies property to the InjectOptions interface type definition

* Add type unit test to InjectOptions cookies property
  • Loading branch information
gyszalai authored Mar 3, 2020
1 parent 150ab0b commit 29204ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ declare namespace LightMyRequest {
validate?: boolean
payload?: InjectPayload
server?: http.Server
cookies?: { [k: string]: string }
}

interface Request extends stream.Readable {
Expand Down
8 changes: 8 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ inject(dispatch, { method: 'get', url: '/' }, (err, res) => {
console.log(res.cookies)
})

inject(dispatch, { method: 'get', url: '/', cookies: { name1: 'value1', value2: 'value2' } }, (err, res) => {
expectType<Error>(err)
expectType<Response>(res)
console.log(res.payload)
expectType<Function>(res.json)
console.log(res.cookies)
})

inject(dispatch)
.get('/')
.end((err, res) => {
Expand Down

0 comments on commit 29204ab

Please sign in to comment.