@@ -187,6 +187,70 @@ void main() {
187187 ).called (1 );
188188 });
189189
190+ test ("applies timeouts from context" , () async {
191+ when (
192+ client.post <dynamic >(
193+ any,
194+ data: anyNamed ("data" ),
195+ options: anyNamed ("options" ),
196+ ),
197+ ).thenAnswer (
198+ (invocation) {
199+ final options = invocation.namedArguments.entries
200+ .firstWhere ((element) => element.key == Symbol ("options" ))
201+ .value as dio.Options ;
202+ return Future .value (
203+ dio.Response <Map <String , dynamic >>(
204+ data: < String , dynamic > {
205+ "data" : < String , dynamic > {},
206+ },
207+ statusCode: 200 ,
208+ requestOptions: dio.RequestOptions (
209+ path: path,
210+ headers: options.headers,
211+ ),
212+ ),
213+ );
214+ },
215+ );
216+
217+ await execute (
218+ Request (
219+ operation: Operation (
220+ document: parseString ("query MyQuery {}" ),
221+ ),
222+ variables: const < String , dynamic > {"i" : 12 },
223+ context: Context .fromList (
224+ const [
225+ DioLinkTimeoutContextEntry (
226+ sendTimeout: Duration (seconds: 20 ),
227+ receiveTimeout: Duration (seconds: 20 ),
228+ ),
229+ ],
230+ ),
231+ ),
232+ ).first;
233+
234+ verify (
235+ client.post <dynamic >(
236+ any,
237+ data: anyNamed ("data" ),
238+ options: argThat (
239+ predicate ((dio.Options o) => o.extEqual (dio.Options (
240+ sendTimeout: const Duration (seconds: 20 ),
241+ receiveTimeout: const Duration (seconds: 20 ),
242+ responseType: dio.ResponseType .json,
243+ headers: < String , dynamic > {
244+ dio.Headers .contentTypeHeader: dio.Headers .jsonContentType,
245+ dio.Headers .acceptHeader: "*/*" ,
246+ },
247+ ))),
248+ named: "options" ,
249+ ),
250+ ),
251+ ).called (1 );
252+ });
253+
190254 test ("adds headers from context" , () async {
191255 when (
192256 client.post <dynamic >(
0 commit comments