File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,20 @@ describe('fixRequestBody', () => {
57
57
expect ( proxyRequest . write ) . toHaveBeenCalled ( ) ;
58
58
} ) ;
59
59
60
+ it ( 'should write when body is not empty and Content-Type is text/plain' , ( ) => {
61
+ const proxyRequest = fakeProxyRequest ( ) ;
62
+ proxyRequest . setHeader ( 'content-type' , 'text/plain; charset=utf-8' ) ;
63
+
64
+ jest . spyOn ( proxyRequest , 'setHeader' ) ;
65
+ jest . spyOn ( proxyRequest , 'write' ) ;
66
+
67
+ fixRequestBody ( proxyRequest , createRequestWithBody ( 'some string' ) ) ;
68
+
69
+ const expectedBody = 'some string' ;
70
+ expect ( proxyRequest . setHeader ) . toHaveBeenCalledWith ( 'Content-Length' , expectedBody . length ) ;
71
+ expect ( proxyRequest . write ) . toHaveBeenCalledWith ( expectedBody ) ;
72
+ } ) ;
73
+
60
74
it ( 'should write when body is not empty and Content-Type is application/json' , ( ) => {
61
75
const proxyRequest = fakeProxyRequest ( ) ;
62
76
proxyRequest . setHeader ( 'content-type' , 'application/json; charset=utf-8' ) ;
You can’t perform that action at this time.
0 commit comments