File tree Expand file tree Collapse file tree 4 files changed +69
-42
lines changed
Expand file tree Collapse file tree 4 files changed +69
-42
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const assert = require ( 'assert' )
4+ const http = require ( 'http' )
45const Ajv = require ( 'ajv' )
56const Request = require ( './lib/request' )
67const Response = require ( './lib/response' )
@@ -41,7 +42,7 @@ const schema = {
4142 } ,
4243 authority : { type : 'string' } ,
4344 remoteAddress : { type : 'string' } ,
44- method : { type : 'string' } ,
45+ method : { type : 'string' , enum : http . METHODS . concat ( http . METHODS . map ( toLowerCase ) ) } ,
4546 validate : { type : 'boolean' }
4647 // payload type => any
4748 } ,
@@ -83,5 +84,7 @@ function isInjection (obj) {
8384 return ( obj instanceof Request || obj instanceof Response )
8485}
8586
87+ function toLowerCase ( m ) { return m . toLowerCase ( ) }
88+
8689module . exports = inject
8790module . exports . isInjection = isInjection
Original file line number Diff line number Diff line change 1414 "tap" : " ^11.0.1"
1515 },
1616 "scripts" : {
17- "test" : " standard && tap test/test.js"
17+ "test" : " npm run lint && npm run unit" ,
18+ "lint" : " standard" ,
19+ "unit" : " tap test/test.js" ,
20+ "coverage" : " npm run unit -- --cov --coverage-report=html"
1821 },
1922 "repository" : {
2023 "type" : " git" ,
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ function asyncAwaitTest (t, inject) {
1010 }
1111
1212 try {
13- const res = await inject ( dispatch , { method : 'get ' , url : 'http://example.com:8080/hello' } )
13+ const res = await inject ( dispatch , { method : 'GET ' , url : 'http://example.com:8080/hello' } )
1414 t . equal ( res . payload , 'hello' )
1515 } catch ( err ) {
1616 t . fail ( err )
@@ -23,7 +23,7 @@ function asyncAwaitTest (t, inject) {
2323 }
2424
2525 try {
26- await inject ( dispatch , { method : 'get ' , url : 'http://example.com:8080/hello' } )
26+ await inject ( dispatch , { method : 'GET ' , url : 'http://example.com:8080/hello' } )
2727 t . fail ( 'should throw' )
2828 } catch ( err ) {
2929 t . ok ( err )
You can’t perform that action at this time.
0 commit comments