Skip to content

Commit

Permalink
Merge pull request #48 from zigomir/fix-params
Browse files Browse the repository at this point in the history
Fix params
  • Loading branch information
syumai authored Nov 11, 2019
2 parents 7aea8dd + ef6490e commit 953cccf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ function isStatusHeadersBodyResponse(
res: Response
): res is StatusHeadersBodyResponse {
const r = res as StatusHeadersBodyResponse;
return r.length && r.length === 3;
return Array.isArray(r) && r.length === 3;
}

function isStatusBodyResponse(res: Response): res is StatusBodyResponse {
const r = res as StatusBodyResponse;
return r.length && r.length === 2;
return Array.isArray(r) && r.length === 2;
}

function isNumberResponse(res: Response): res is number {
Expand Down
16 changes: 15 additions & 1 deletion serve_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,26 @@ const testCases: Array<testCase> = [
expected: 'basic',
},
{
name: 'valid basic handler with path parameter',
name: 'valid basic handler with path parameter 1',
registered: get('/parameters/:param', ({ params }) => params.param),
path: 'parameters/p',
method: Method.GET,
expected: 'p',
},
{
name: 'valid basic handler with path parameter 2',
registered: get('/parameters/:param', ({ params }) => params.param),
path: 'parameters/pa',
method: Method.GET,
expected: 'pa',
},
{
name: 'valid basic handler with path parameter 3',
registered: get('/parameters/:param', ({ params }) => params.param),
path: 'parameters/pat',
method: Method.GET,
expected: 'pat',
},
{
name: 'valid basic handler with path parameters',
registered: get('/parameters/:param1/:param2', ({ params }) => `${params.param1} ${params.param2}`),
Expand Down

0 comments on commit 953cccf

Please sign in to comment.