|
| 1 | +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:cupertino_http/cupertino_http.dart'; |
| 6 | +import 'package:flutter_test/flutter_test.dart'; |
| 7 | +import 'package:integration_test/integration_test.dart'; |
| 8 | +import 'package:objective_c/objective_c.dart'; |
| 9 | + |
| 10 | +void main() { |
| 11 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 12 | + |
| 13 | + group('NSErrorClientException', () { |
| 14 | + late CupertinoClient client; |
| 15 | + |
| 16 | + setUpAll(() => client = CupertinoClient.defaultSessionConfiguration()); |
| 17 | + tearDownAll(() => client.close()); |
| 18 | + |
| 19 | + test('thrown', () async { |
| 20 | + expect( |
| 21 | + () => client.get(Uri.http('doesnotexist', '/')), |
| 22 | + throwsA(isA<NSErrorClientException>() |
| 23 | + .having((e) => e.error.domain.toDartString(), 'error.domain', |
| 24 | + 'NSURLErrorDomain') |
| 25 | + .having((e) => e.error.code, 'error.code', -1003) |
| 26 | + .having( |
| 27 | + (e) => e.toString(), |
| 28 | + 'toString()', |
| 29 | + 'NSErrorClientException: A server with the specified ' |
| 30 | + 'hostname could not be found. ' |
| 31 | + '[domain=NSURLErrorDomain, code=-1003], ' |
| 32 | + 'uri=http://doesnotexist/'))); |
| 33 | + }); |
| 34 | + }); |
| 35 | +} |
0 commit comments