Skip to content
Myr

Pass the tests

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 072196c · Browse files · 6 files+24 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+24 added−7 removed

  • tests:+13 added−1 removed
  • other:+11 added−6 removed

6 files+24 added−7 removed

modified:src/hono.js+5 added-1 removed
modified:src/node.js+4 added-3 removed
1'use strict'23const { splitPath, getPattern, getParamName } = require('./util')45const METHOD_NAME_OF_ALL = 'all'6
13 unmodified lines
2021 insert(method, path, handler) {22 let curNode = this23 for (const p of splitPath(path)) {22 const nextNode = curNode.children[p]23 if (nextNode) {24 curNode = nextNode24 if (Object.keys(curNode.children).includes(p)) {25 curNode = curNode.children[p]26 continue27 }28 curNode.children[p] = new Node({29 label: p,
67 unmodified lines
modified:src/node.test.js+8 added
79 unmodified lines
80 expect(res.handler).toBe('get comment')81 expect(res.params['id']).toBe('789')82 expect(res.params['comment_id']).toBe('123')83 })8485 it('get /map/:location/events', () => {86 node.insert('get', '/map/:location/events', 'get events')87 let res = node.search('get', '/map/yokohama/events')88 expect(res).not.toBeNull()89 expect(res.handler).toBe('get events')90 expect(res.params['location']).toBe('yokohama')91 })92})9394describe('Wildcard', () => {95 const node = new Node()
44 unmodified lines
modified:src/router.test.js+1 added-1 removed
1const App = require('./hono')23describe('Basic Usage', () => {4 let router = App()4 const router = App()56 it('get, post hello', () => {7 router.get('/hello', 'get hello')8 router.post('/hello', 'post hello')
76 unmodified lines
modified:src/util.test.js+4 added
modified:package.json+2 added-2 removed