Skip to content

Commit 7077b38

Browse files
add test for http client logger
1 parent 972e449 commit 7077b38

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/instabug_flutter_test.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ import 'package:instabug_flutter/InstabugLog.dart';
1515
import 'package:instabug_flutter/NetworkLogger.dart';
1616
import 'package:instabug_flutter/Replies.dart';
1717
import 'package:instabug_flutter/Surveys.dart';
18+
import 'package:instabug_flutter/instabug_custom_http_client.dart';
1819
import 'package:instabug_flutter/models/crash_data.dart';
1920
import 'package:instabug_flutter/models/exception_data.dart';
2021
import 'package:instabug_flutter/models/network_data.dart';
22+
import 'package:instabug_flutter/utils/http_client_logger.dart';
2123
import 'package:instabug_flutter/utils/platform_manager.dart';
2224
import 'package:mockito/annotations.dart';
2325
import 'package:mockito/mockito.dart';
@@ -73,6 +75,8 @@ void main() {
7375
status: status,
7476
);
7577

78+
final HttpClientLogger logger = HttpClientLogger();
79+
7680
setUpAll(() async {
7781
const MethodChannel('instabug_flutter')
7882
.setMockMethodCallHandler((MethodCall methodCall) async {
@@ -965,4 +969,14 @@ void main() {
965969
expect(newNetworkData.endTime, endDateCopy);
966970
expect(newNetworkData.status, statusCopy);
967971
});
972+
973+
test('Test Http client logger', () async {
974+
final InstabugCustomHttpClient client = InstabugCustomHttpClient();
975+
final HttpClientRequest request = await client
976+
.getUrl(Uri.parse('https://jsonplaceholder.typicode.com/posts'));
977+
client.logger.onRequest(request);
978+
final HttpClientResponse response = await request.close();
979+
client.logger.onResponse(response, request);
980+
expect(client.requests.length, 0);
981+
});
968982
}

0 commit comments

Comments
 (0)