Skip to content

Commit 14554f7

Browse files
Add test coverage for Replies
1 parent 6e6f105 commit 14554f7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

lib/Replies.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// ignore_for_file: avoid_classes_with_only_static_members
22

33
import 'dart:async';
4-
import 'dart:io' show Platform;
54

65
import 'package:flutter/services.dart';
6+
import 'package:instabug_flutter/utils/platform_manager.dart';
77

88
class Replies {
99
static Function? _hasChatsCallback;
@@ -78,7 +78,7 @@ class Replies {
7878
/// [isEnabled] A boolean to set whether notifications sound should be played.
7979
/// @android ONLY
8080
static Future<void> setInAppNotificationSound(bool isEnabled) async {
81-
if (Platform.isAndroid) {
81+
if (PlatformManager.instance.isAndroid()) {
8282
final List<dynamic> params = <dynamic>[isEnabled];
8383
await _channel.invokeMethod<Object>(
8484
'setEnableInAppNotificationSound:', params);

test/instabug_flutter_test.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,21 @@ void main() {
770770
]);
771771
});
772772

773+
test('setInAppNotificationSound: Test', () async {
774+
const isEnabled = false;
775+
final List<dynamic> args = <dynamic>[isEnabled];
776+
777+
when(mockPlatform.isAndroid()).thenAnswer((_) => true);
778+
779+
Replies.setInAppNotificationSound(isEnabled);
780+
expect(log, <Matcher>[
781+
isMethodCall(
782+
'setEnableInAppNotificationSound:',
783+
arguments: args,
784+
)
785+
]);
786+
});
787+
773788
test('showReplies Test', () async {
774789
Replies.show();
775790
expect(log, <Matcher>[isMethodCall('showReplies', arguments: null)]);
@@ -844,17 +859,4 @@ void main() {
844859
]);
845860
}
846861
});
847-
848-
///Since the below method only runs on android and has the [Platform.isAndroid] condition in it, it will fail when running outside android,
849-
/// therefore its commented.
850-
// test('setEnableInAppNotificationSound: Test', () async {
851-
// bool isEnabled = false;
852-
// final List<dynamic> args = <dynamic>[isEnabled];
853-
// Replies.setInAppNotificationSound(isEnabled);
854-
// expect(log, <Matcher>[
855-
// isMethodCall('setEnableInAppNotificationSound:',
856-
// arguments: args,
857-
// )
858-
// ]);
859-
// });
860862
}

0 commit comments

Comments
 (0)