@@ -87,6 +87,26 @@ describe("Interaction", () => {
87
87
expect ( actual . request ) . to . have . keys ( "method" , "path" , "query" , "headers" , "body" ) ;
88
88
} ) ;
89
89
} ) ;
90
+
91
+ describe ( "request body" , ( ) => {
92
+ it ( "is included when an empty string is specified" , ( ) => {
93
+ const actual = new Interaction ( ) . withRequest ( {
94
+ body : "" ,
95
+ method : HTTPMethod . GET ,
96
+ path : "/path" ,
97
+ } ) . json ( ) ;
98
+ expect ( actual . request ) . to . have . any . keys ( "body" ) ;
99
+ } ) ;
100
+
101
+ it ( "is not included when explicitly set to undefined" , ( ) => {
102
+ const actual = new Interaction ( ) . withRequest ( {
103
+ body : undefined ,
104
+ method : HTTPMethod . GET ,
105
+ path : "/path" ,
106
+ } ) . json ( ) ;
107
+ expect ( actual . request ) . not . to . have . any . keys ( "body" ) ;
108
+ } ) ;
109
+ } ) ;
90
110
} ) ;
91
111
92
112
describe ( "#willRespondWith" , ( ) => {
@@ -131,5 +151,27 @@ describe("Interaction", () => {
131
151
expect ( actual . response ) . to . have . keys ( "status" , "headers" , "body" ) ;
132
152
} ) ;
133
153
} ) ;
154
+
155
+ describe ( "response body" , ( ) => {
156
+ it ( "is included when an empty string is specified" , ( ) => {
157
+ interaction = new Interaction ( ) ;
158
+ interaction . willRespondWith ( {
159
+ body : "" ,
160
+ status : 204 ,
161
+ } ) ;
162
+ const actual = interaction . json ( ) ;
163
+ expect ( actual . response ) . to . have . any . keys ( "body" ) ;
164
+ } ) ;
165
+
166
+ it ( "is not included when explicitly set to undefined" , ( ) => {
167
+ interaction = new Interaction ( ) ;
168
+ interaction . willRespondWith ( {
169
+ body : undefined ,
170
+ status : 204 ,
171
+ } ) ;
172
+ const actual = interaction . json ( ) ;
173
+ expect ( actual . response ) . not . to . have . any . keys ( "body" ) ;
174
+ } ) ;
175
+ } ) ;
134
176
} ) ;
135
177
} ) ;
0 commit comments