Url Launcher Test - Dart
Url Launcher Test - Dart
Url Launcher Test - Dart
import 'dart:async';
import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:flutter/foundation.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.
dart';
import 'package:flutter/services.dart' show PlatformException;
void main() {
final MockUrlLauncher mock = MockUrlLauncher();
UrlLauncherPlatform.instance = mock;
group('canLaunch', () {
test('returns true', () async {
when(mock.canLaunch('foo')).thenAnswer((_) => Future<bool>.value(true));
expect(result, isTrue);
});
expect(result, isFalse);
});
});
group('launch', () {
test('requires a non-null urlString', () {
expect(() => launch(null), throwsAssertionError);
});