@@ -243,6 +243,37 @@ describe('HTTP Router', () => {
243243 req . method . should . eql ( 'POST' )
244244 } )
245245
246+ it ( 'should forward PATCH requests correctly' , async ( ) => {
247+ const response = 'Hello Patch'
248+ const patchSpy = sinon . spy ( ( ) => response )
249+ server = await testUtils . createMockHttpServer (
250+ patchSpy ,
251+ constants . HTTP_PORT ,
252+ 200
253+ )
254+
255+ const channel = {
256+ name : 'PATCH channel' ,
257+ urlPattern : '.+' ,
258+ routes : [
259+ {
260+ host : 'localhost' ,
261+ port : constants . HTTP_PORT ,
262+ primary : true
263+ }
264+ ]
265+ }
266+ const ctx = createContext ( channel , '/test' , 'PATCH' , 'some body' )
267+ await promisify ( router . route ) ( ctx )
268+ Buffer . isBuffer ( ctx . response . body ) . should . be . true ( )
269+ ctx . response . body . toString ( ) . should . eql ( response )
270+
271+ patchSpy . callCount . should . be . eql ( 1 )
272+ const call = patchSpy . getCall ( 0 )
273+ const req = call . args [ 0 ]
274+ req . method . should . eql ( 'PATCH' )
275+ } )
276+
246277 it ( 'should handle empty put and post requests correctly' , async ( ) => {
247278 const response = 'Hello Empty Post'
248279 const postSpy = sinon . spy ( ( ) => response )
@@ -273,6 +304,36 @@ describe('HTTP Router', () => {
273304 req . method . should . eql ( 'POST' )
274305 } )
275306
307+ it ( 'should handle empty patch requests correctly' , async ( ) => {
308+ const response = 'Hello Empty Patch'
309+ const patchSpy = sinon . spy ( ( ) => response )
310+ server = await testUtils . createMockHttpServer (
311+ patchSpy ,
312+ constants . HTTP_PORT ,
313+ 200
314+ )
315+ const channel = {
316+ name : 'PATCH channel' ,
317+ urlPattern : '.+' ,
318+ routes : [
319+ {
320+ host : 'localhost' ,
321+ port : constants . HTTP_PORT ,
322+ primary : true
323+ }
324+ ]
325+ }
326+ const ctx = createContext ( channel , '/test' , 'PATCH' )
327+ await promisify ( router . route ) ( ctx )
328+ Buffer . isBuffer ( ctx . response . body ) . should . be . true ( )
329+ ctx . response . body . toString ( ) . should . eql ( response )
330+
331+ patchSpy . callCount . should . be . eql ( 1 )
332+ const call = patchSpy . getCall ( 0 )
333+ const req = call . args [ 0 ]
334+ req . method . should . eql ( 'PATCH' )
335+ } )
336+
276337 it ( 'should send request params if these where received from the incoming request' , async ( ) => {
277338 const requestSpy = sinon . spy ( ( ) => { } )
278339 server = await testUtils . createMockHttpServer (
0 commit comments