projectName_test.dart.tmpl 1.11 KB
Newer Older
1 2
import 'package:flutter_test/flutter_test.dart';
import 'package:{{projectName}}/{{projectName}}.dart';
3 4 5
import 'package:{{projectName}}/{{projectName}}_platform_interface.dart';
import 'package:{{projectName}}/{{projectName}}_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
6

7
class Mock{{pluginDartClass}}Platform
8 9
    with MockPlatformInterfaceMixin
    implements {{pluginDartClass}}Platform {
10

11 12 13
  @override
  Future<String?> getPlatformVersion() => Future.value('42');
}
14

15 16
void main() {
  final {{pluginDartClass}}Platform initialPlatform = {{pluginDartClass}}Platform.instance;
17

18 19
  test('$MethodChannel{{pluginDartClass}} is the default instance', () {
    expect(initialPlatform, isInstanceOf<MethodChannel{{pluginDartClass}}>());
20 21 22
  });

  test('getPlatformVersion', () async {
23 24 25
    {{pluginDartClass}} {{pluginClassLowerCamelCase}} = {{pluginDartClass}}();
    Mock{{pluginDartClass}}Platform fakePlatform = Mock{{pluginDartClass}}Platform();
    {{pluginDartClass}}Platform.instance = fakePlatform;
26

27
    expect(await {{pluginClassLowerCamelCase}}.getPlatformVersion(), '42');
28 29
  });
}