0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 10:51:01 +00:00
hono/src/hono.test.js

30 lines
710 B
JavaScript
Raw Normal View History

2021-12-14 19:58:45 +00:00
const Hono = require('./hono')
const fetch = require('node-fetch')
const app = new Hono()
describe('GET match', () => {
app.get('/hello', () => {
return new fetch.Response('hello', {
status: 200
})
})
app.notFound = () => {
return new fetch.Response('not found', {
status: 404
})
}
it('GET /hello is ok', () => {
let req = new fetch.Request('https://example.com/hello')
let res = app.dispatch(req)
expect(res).not.toBeNull()
expect(res.status).toBe(200)
})
it('GET / is not found', () => {
let req = new fetch.Request('https://example.com/')
let res = app.dispatch(req)
expect(res).not.toBeNull()
expect(res.status).toBe(404)
})
})