Skip to content

Commit

Permalink
bump deps and fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
v1rtl committed Aug 3, 2023
1 parent 26a342c commit a08ace0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
33 changes: 33 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export { expect } from 'https://deno.land/x/[email protected]/mod.ts'
export {
assertEquals,
assertMatch,
} from 'https://deno.land/[email protected]/testing/asserts.ts'
export { expect } from 'https://deno.land/x/[email protected]/mod.ts'
export { assertEquals } from 'https://deno.land/[email protected]/assert/assert_equals.ts'
export { assertMatch } from 'https://deno.land/[email protected]/assert/assert_match.ts'
18 changes: 6 additions & 12 deletions mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'https://deno.land/x/[email protected]/mod.ts'
import { makeFetch } from './mod.ts'
import { Handler } from './types.ts'
import { AssertionError } from 'https://deno.land/std@0.182.0/testing/asserts.ts'
import { AssertionError } from 'https://deno.land/std@0.197.0/assert/assertion_error.ts'

// this simulates the listener
class PseudoListener {
Expand Down Expand Up @@ -37,9 +37,7 @@ class PseudoListener {
this.conn = await this.#listener.accept()
const httpConn = Deno.serveHttp(this.conn)
const requestEvent = await httpConn.nextRequest()
requestEvent?.respondWith(
new Response('hello', { status: 200 }),
)
requestEvent?.respondWith(new Response('hello', { status: 200 }))
resolve(this.conn)
})
}
Expand Down Expand Up @@ -207,7 +205,7 @@ describe('expectHeader', () => {
})
it('can expect array of header values', async () => {
const handler: Handler = () =>
new Response('Hello World', { headers: { 'A': '1,2,3' } })
new Response('Hello World', { headers: { A: '1,2,3' } })
const fetch = makeFetch(handler)
const res = await fetch('/')
res.expectHeader('A', ['1', '2', '3'])
Expand Down Expand Up @@ -260,7 +258,7 @@ describe('expect', () => {
it('uses expectHeader if two arguments', async () => {
const handler: Handler = () =>
new Response('Hello World', {
'headers': { 'Content-Type': 'text/plain' },
headers: { 'Content-Type': 'text/plain' },
})
const fetch = makeFetch(handler)
const res = await fetch('/')
Expand All @@ -286,9 +284,7 @@ describe('Deno listener', () => {
const fetch = makeFetch(listener as Deno.Listener)
await fetch('/')
} catch (e) {
expect((e as Error).message).toMatch(
'Port cannot be found',
)
expect((e as Error).message).toMatch('Port cannot be found')
if (listener.conn?.rid) Deno.close(listener.conn?.rid + 1)
listener.close()
}
Expand Down Expand Up @@ -322,9 +318,7 @@ describe('Port randomness', () => {
const fetch = makeFetch(handler)
await fetch('/')
} catch (e) {
expect((e as Error).message).toMatch(
'Unable to get free port',
)
expect((e as Error).message).toMatch('Unable to get free port')
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Handler = (
request: Request,
connInfo: Deno.Conn
connInfo: Deno.Conn,
) => Response | Promise<Response>

export type HandlerOrListener = Handler | Deno.Listener

0 comments on commit a08ace0

Please sign in to comment.