@@ -5,35 +5,88 @@ import { describe, expect, test as it } from "vitest";
55describe ( "middleware-expect-continue" ,  ( )  =>  { 
66  describe ( S3 . name ,  ( )  =>  { 
77    it ( "should not set expect header if there is no body" ,  async  ( )  =>  { 
8-       const  client  =  new  S3 ( {  region : "us-west-2"  } ) ; 
9- 
8+       const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : true  } ) ; 
109      requireRequestsFrom ( client ) . toMatch ( { 
1110        headers : { 
1211          Expect : / u n d e f i n e d / , 
1312        } , 
1413      } ) ; 
15- 
1614      await  client . listBuckets ( { } ) ; 
17- 
1815      expect . assertions ( 1 ) ; 
1916    } ) ; 
2017
2118    it ( "should set expect header if there is a body" ,  async  ( )  =>  { 
22-       const  client  =  new  S3 ( {  region : "us-west-2"  } ) ; 
23- 
19+       const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : 4  } ) ; 
2420      requireRequestsFrom ( client ) . toMatch ( { 
2521        headers : { 
2622          Expect : / 1 0 0 - c o n t i n u e / , 
2723        } , 
2824      } ) ; 
29- 
3025      await  client . putObject ( { 
3126        Bucket : "b" , 
3227        Key : "k" , 
3328        Body : Buffer . from ( "abcd" ) , 
3429      } ) ; 
35- 
3630      expect . assertions ( 1 ) ; 
3731    } ) ; 
32+ 
33+     describe ( "should set or omit expect header based on configurations" ,  ( )  =>  { 
34+       it ( "false" ,  async  ( )  =>  { 
35+         const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : false  } ) ; 
36+         requireRequestsFrom ( client ) . toMatch ( { 
37+           headers : { 
38+             Expect : / u n d e f i n e d / , 
39+           } , 
40+         } ) ; 
41+         await  client . putObject ( { 
42+           Bucket : "b" , 
43+           Key : "k" , 
44+           Body : Buffer . from ( "abcd" ) , 
45+         } ) ; 
46+         expect . assertions ( 1 ) ; 
47+       } ) ; 
48+       it ( "5" ,  async  ( )  =>  { 
49+         const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : 5  } ) ; 
50+         requireRequestsFrom ( client ) . toMatch ( { 
51+           headers : { 
52+             Expect : / u n d e f i n e d / , 
53+           } , 
54+         } ) ; 
55+         await  client . putObject ( { 
56+           Bucket : "b" , 
57+           Key : "k" , 
58+           Body : Buffer . from ( "abcd" ) , 
59+         } ) ; 
60+         expect . assertions ( 1 ) ; 
61+       } ) ; 
62+       it ( "true" ,  async  ( )  =>  { 
63+         const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : true  } ) ; 
64+         requireRequestsFrom ( client ) . toMatch ( { 
65+           headers : { 
66+             Expect : / 1 0 0 - c o n t i n u e / , 
67+           } , 
68+         } ) ; 
69+         await  client . putObject ( { 
70+           Bucket : "b" , 
71+           Key : "k" , 
72+           Body : Buffer . from ( "abcd" ) , 
73+         } ) ; 
74+         expect . assertions ( 1 ) ; 
75+       } ) ; 
76+       it ( "4" ,  async  ( )  =>  { 
77+         const  client  =  new  S3 ( {  region : "us-west-2" ,  expectContinueHeader : 4  } ) ; 
78+         requireRequestsFrom ( client ) . toMatch ( { 
79+           headers : { 
80+             Expect : / 1 0 0 - c o n t i n u e / , 
81+           } , 
82+         } ) ; 
83+         await  client . putObject ( { 
84+           Bucket : "b" , 
85+           Key : "k" , 
86+           Body : Buffer . from ( "abcd" ) , 
87+         } ) ; 
88+         expect . assertions ( 1 ) ; 
89+       } ) ; 
90+     } ) ; 
3891  } ) ; 
3992} ) ; 
0 commit comments