add platform_detector_test.dart

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-06-03 22:29:52 +05:30
parent 7a95192093
commit 473851684b
2 changed files with 27 additions and 3 deletions
@@ -0,0 +1,25 @@
@TestOn('linux')
import 'package:stream_chat/src/core/platform_detector/platform_detector.dart';
import 'package:test/test.dart';
void main() {
test('`.type` should return current platform', () {
final type = CurrentPlatform.type;
expect(type, PlatformType.linux);
});
test('`.name` should return current platform name', () {
final name = CurrentPlatform.name;
expect(name, 'linux');
});
test('flags', () {
expect(CurrentPlatform.isWeb, isFalse);
expect(CurrentPlatform.isIos, isFalse);
expect(CurrentPlatform.isLinux, isTrue);
expect(CurrentPlatform.isAndroid, isFalse);
expect(CurrentPlatform.isMacOS, isFalse);
expect(CurrentPlatform.isWindows, isFalse);
expect(CurrentPlatform.isFuchsia, isFalse);
});
}
@@ -45,11 +45,10 @@ void main() {
webSocketController.add(invocation.positionalArguments.first);
});
when(() => webSocketSink.close(any(), any())).thenAnswer(
(_) {
final res = webSocketController.close();
(_) async {
webSocketController.close();
// re-initializing for future events
webSocketController = StreamController<String>.broadcast();
return res;
},
);
});