chore: fixed typo
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yusuke Wada · committed by Yusuke Wada · parent 798425a · Browse files · 8 files·+15 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+15 added−15 removed
- tests:+12 added−12 removed
- other:+3 added−3 removed
Provenance
- Commit
f1be3af- Tree
057fc71- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
Yusuke Wada <yusuke@kamawada.com>- Parent
798425a
8 files changed+15 added−15 removed
modified:src/middleware/logger/index.test.ts+1 added-1 removed
43 unmodified lines444546474848495051528 unmodified lines43 unmodified lines expect(log.endsWith(` ${longRandomString.length / 1024}kB`)).toBe(true) })
it('Log status 404', async () => { const msg = 'Default 404 Nout Found' const msg = 'Default 404 Not Found' app.all('*', (c) => { return c.text(msg, 404) })
8 unmodified linesmodified:src/middleware/logger/index.ts+2 added-2 removed
40 unmodified lines414243444545464748495051515253545516 unmodified lines40 unmodified lines prefix: string, method: string, path: string, status?: number, elasped?: string, elapsed?: string, contentLength?: string) { const out = prefix === LogPrefix.Incoming ? ` ${prefix} ${method} ${path}` : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elasped} ${contentLength}` : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed} ${contentLength}` fn(out)}
export const logger = (fn = console.log) => {16 unmodified linesmodified:src/middleware/mustache/index.test.ts+2 added-2 removed
42 unmodified lines4344454647474849505152535454555657582 unmodified lines42 unmodified lines app.get('/bar', (c) => { return c.render('index') })
it('Mustache template redering', async () => { it('Mustache template rendering', async () => { const req = new Request('http://localhost/foo') const res = await app.dispatch(req) expect(res.status).toBe(200) expect(await res.text()).toBe('<html><body>Title: Hono!</body></html>') })
it('Mustache template redering with root', async () => { it('Mustache template rendering with root', async () => { const req = new Request('http://localhost/bar') const res = await app.dispatch(req) expect(res.status).toBe(200) expect(await res.text()).toBe('<h1>With Root</h1>')2 unmodified linesmodified:src/utils/body.test.ts+1 added-1 removed
32 unmodified lines33 })34 expect(await parseBody(req)).toEqual({ message: 'hello' })35 })36 37- it('should parse Reponse body ', async () => {37+ it('should parse Response body ', async () => {38 const payload = 'hello'39 const res = new Response(payload, {40 headers: {41 'Content-Type': 'text/plain',6 unmodified linesmodified:src/utils/crypto.test.ts+2 added-2 removed
15 unmodified lines16 expect(await sha1('炎')).toBe('d56e09ae2421b2b8a0b5ee5fdceaed663c8c9472')17 expect(await sha1('abcdedf')).not.toBe('abcdef')18 })19 20- it('encodeBaes64', () => {20+ it('encodeBase64', () => {21 expect(encodeBase64('hooooooooo')).toBe('aG9vb29vb29vbw==')22 expect(encodeBase64('炎')).toBe('54KO')23 expect(encodeBase64('abcdef')).not.toBe('abcdedf')24 expect(encodeBase64('')).toBe('')1 unmodified line26 encodeBase64(null)27 }).toThrow(TypeError)28 })29 30- it('decodeBaes64', async () => {30+ it('decodeBase64', async () => {31 expect(decodeBase64('aG9vb29vb29vbw==')).toBe('hooooooooo')32 expect(decodeBase64('54KO')).toBe('炎')33 expect(decodeBase64('abcdedf')).not.toBe('abcdef')34 expect(decodeBase64('')).toBe('')5 unmodified linesmodified:src/context.test.ts+2 added-2 removed
72 unmodified lines73 expect(res.status).toBe(201)74 expect(res.statusText).toBe('Created')75 })76 77- it('Complext pattern', async () => {77+ it('Complex pattern', async () => {78 c.status(404)79 const res = c.json({ hono: 'great app' })80 expect(res.status).toBe(404)81 expect(res.statusText).toBe('Not Found')25 unmodified lines107 expect(res.headers.get('X-Custom3')).toBe('Message3')108 expect(res.status).toBe(201)109 expect(await res.text()).toBe('this is body')110 111- // res is already setted.111+ // res is already set.112 c.res = res113 c.header('X-Custom4', 'Message4')114 c.status(202)115 expect(c.res.headers.get('X-Custom4')).toBe('Message4')10 unmodified linesmodified:src/hono.test.ts+4 added-4 removed
116 unmodified lines117 book.post('/', (c) => c.text('post /book'))118 119 const user = app.route('/user')120 user.get('/login', (c) => c.text('get /user/login'))121- user.post('/regist', (c) => c.text('post /user/regist'))121+ user.post('/register', (c) => c.text('post /user/register'))122 123 let res = await app.request('http://localhost/book', { method: 'GET' })124 expect(res.status).toBe(200)125 expect(await res.text()).toBe('get /book')12 unmodified lines138 res = await app.request('http://localhost/user/login', { method: 'GET' })139 expect(res.status).toBe(200)140 expect(await res.text()).toBe('get /user/login')141 142- res = await app.request('http://localhost/user/regist', { method: 'POST' })142+ res = await app.request('http://localhost/user/register', { method: 'POST' })143 expect(res.status).toBe(200)144- expect(await res.text()).toBe('post /user/regist')144+ expect(await res.text()).toBe('post /user/register')145 })146 })147 148 describe('param and query', () => {43 unmodified lines192 console.log(`${c.req.method} : ${c.req.url}`)193 await next()194 })195 196- // Apeend Custom Header196+ // Append Custom Header197 app.use('*', async (c, next) => {198 await next()199 c.res.headers.append('x-custom', 'root')200 })145 unmodified linesmodified:src/hono.ts+1 added-1 removed
186 unmodified lines187 188 const wrappedHandler = async (context: Context, next: Next) => {189 const res = await handler(context)190 if (!(res instanceof Response)) {191- throw new TypeError('response must be a instace of Response')191+ throw new TypeError('response must be a instance of Response')192 }193 context.res = res194 await next()195 }31 unmodified lines