1
- import { Request } from 'express' ;
2
- import { ClientRequest , ServerResponse } from 'http' ;
1
+ import express from 'express' ;
2
+ import http from 'http' ;
3
3
4
4
import { fixRequestBody } from './fixRequestBody' ;
5
5
6
6
const fakeProxyRequest = ( ) => {
7
- const proxyRequest = new ClientRequest ( 'http://some-host' ) ;
7
+ const proxyRequest = new http . ClientRequest ( 'http://some-host' ) ;
8
8
proxyRequest . emit = jest . fn ( ) ;
9
9
10
10
return proxyRequest ;
@@ -16,7 +16,12 @@ test('should not write when body is undefined', () => {
16
16
jest . spyOn ( proxyRequest , 'setHeader' ) ;
17
17
jest . spyOn ( proxyRequest , 'write' ) ;
18
18
19
- fixRequestBody ( proxyRequest , { body : undefined } as Request , { } as ServerResponse , { } ) ;
19
+ fixRequestBody (
20
+ proxyRequest ,
21
+ { body : undefined } as express . Request ,
22
+ { } as http . ServerResponse ,
23
+ { }
24
+ ) ;
20
25
21
26
expect ( proxyRequest . setHeader ) . not . toHaveBeenCalled ( ) ;
22
27
expect ( proxyRequest . write ) . not . toHaveBeenCalled ( ) ;
@@ -28,7 +33,7 @@ test('should not write when body is empty', () => {
28
33
jest . spyOn ( proxyRequest , 'setHeader' ) ;
29
34
jest . spyOn ( proxyRequest , 'write' ) ;
30
35
31
- fixRequestBody ( proxyRequest , { body : { } } as Request , { } as ServerResponse , { } ) ;
36
+ fixRequestBody ( proxyRequest , { body : { } } as express . Request , { } as http . ServerResponse , { } ) ;
32
37
33
38
expect ( proxyRequest . setHeader ) . not . toHaveBeenCalled ( ) ;
34
39
expect ( proxyRequest . write ) . not . toHaveBeenCalled ( ) ;
@@ -43,8 +48,8 @@ test('should write when body is not empty and Content-Type is application/json',
43
48
44
49
fixRequestBody (
45
50
proxyRequest ,
46
- { body : { someField : 'some value' } } as Request ,
47
- { } as ServerResponse ,
51
+ { body : { someField : 'some value' } } as express . Request ,
52
+ { } as http . ServerResponse ,
48
53
{ }
49
54
) ;
50
55
@@ -62,8 +67,8 @@ test('should write when body is not empty and Content-Type is application/x-www-
62
67
63
68
fixRequestBody (
64
69
proxyRequest ,
65
- { body : { someField : 'some value' } } as Request ,
66
- { } as ServerResponse ,
70
+ { body : { someField : 'some value' } } as express . Request ,
71
+ { } as http . ServerResponse ,
67
72
{ }
68
73
) ;
69
74
0 commit comments