@@ -8,8 +8,11 @@ describe("addExpectContinueMiddleware", () => {
8
8
jest . clearAllMocks ( ) ;
9
9
} ) ;
10
10
11
- it ( "sets the Expect header to 100-continue if there is a request body" , async ( ) => {
12
- const handler = addExpectContinueMiddleware ( ) ( mockNextHandler , { } as any ) ;
11
+ it ( "sets the Expect header to 100-continue if there is a request body in node runtime" , async ( ) => {
12
+ const handler = addExpectContinueMiddleware ( { runtime : "node" } ) (
13
+ mockNextHandler ,
14
+ { } as any
15
+ ) ;
13
16
await handler ( {
14
17
input : { } ,
15
18
request : new HttpRequest ( {
@@ -24,8 +27,11 @@ describe("addExpectContinueMiddleware", () => {
24
27
expect ( request . headers [ "Expect" ] ) . toBe ( "100-continue" ) ;
25
28
} ) ;
26
29
27
- it ( "does not set the Expect header to 100-continue if there is no request body" , async ( ) => {
28
- const handler = addExpectContinueMiddleware ( ) ( mockNextHandler , { } as any ) ;
30
+ it ( "does not set the Expect header to 100-continue if there is no request body in node runtime" , async ( ) => {
31
+ const handler = addExpectContinueMiddleware ( { runtime : "node" } ) (
32
+ mockNextHandler ,
33
+ { } as any
34
+ ) ;
29
35
await handler ( {
30
36
input : { } ,
31
37
request : new HttpRequest ( {
@@ -38,4 +44,23 @@ describe("addExpectContinueMiddleware", () => {
38
44
const { request } = mockNextHandler . mock . calls [ 0 ] [ 0 ] ;
39
45
expect ( request . headers [ "Expect" ] ) . toBeUndefined ( ) ;
40
46
} ) ;
47
+
48
+ it ( "does not set the Expect header to 100-continue for browser runtime" , async ( ) => {
49
+ const handler = addExpectContinueMiddleware ( { runtime : "browser" } ) (
50
+ mockNextHandler ,
51
+ { } as any
52
+ ) ;
53
+ await handler ( {
54
+ input : { } ,
55
+ request : new HttpRequest ( {
56
+ body : "foo" ,
57
+ headers : { }
58
+ } )
59
+ } ) ;
60
+
61
+ const { calls } = ( mockNextHandler as any ) . mock ;
62
+ expect ( calls . length ) . toBe ( 1 ) ;
63
+ const { request } = mockNextHandler . mock . calls [ 0 ] [ 0 ] ;
64
+ expect ( request . headers [ "Expect" ] ) . toBeUndefined ( ) ;
65
+ } ) ;
41
66
} ) ;
0 commit comments