honojs-middleware/deno_test/index.test.ts

26 lines
725 B
TypeScript
Raw Normal View History

2022-08-10 00:32:06 +08:00
import { sentry } from '../deno_dist/mod.ts'
2022-08-04 07:54:30 +08:00
import { assertEquals, Hono } from './deps.ts'
// Test just only minimal patterns.
// Because others are tested well in Cloudflare Workers environment already.
2022-08-12 11:41:03 +08:00
// Mock
class Context implements ExecutionContext {
passThroughOnException(): void {
throw new Error('Method not implemented.')
}
async waitUntil(promise: Promise<any>): Promise<void> {
await promise
}
}
2022-08-10 00:32:06 +08:00
Deno.test('Sentry Middleware', async () => {
2022-08-04 07:54:30 +08:00
const app = new Hono()
2022-08-10 00:32:06 +08:00
app.use('/sentry/*', sentry())
app.get('/sentry/foo', (c) => c.text('foo'))
2022-08-04 07:54:30 +08:00
2022-08-12 11:41:03 +08:00
const req = new Request('http://localhost/sentry/foo')
const res = await app.fetch(req, {}, new Context())
2022-08-04 07:54:30 +08:00
assertEquals(res.status, 200)
})