chore: generate template (#17)
This commit is contained in:
committed by
GitHub
parent
5baf0dfa61
commit
699457e663
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2022, Very Good Ventures
|
||||
// https://verygood.ventures
|
||||
//
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file or at
|
||||
// https://opensource.org/licenses/MIT.
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:{{project_name.snakeCase()}}_linux/{{project_name.snakeCase()}}_linux.dart';
|
||||
import 'package:{{project_name.snakeCase()}}_platform_interface/{{project_name.snakeCase()}}_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
group('{{project_name.pascalCase()}}Linux', () {
|
||||
const kPlatformName = 'Linux';
|
||||
late {{project_name.pascalCase()}}Linux {{project_name.camelCase()}};
|
||||
late List<MethodCall> log;
|
||||
|
||||
setUp(() async {
|
||||
{{project_name.camelCase()}} = {{project_name.pascalCase()}}Linux();
|
||||
|
||||
log = <MethodCall>[];
|
||||
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler({{project_name.camelCase()}}.methodChannel, (methodCall) async {
|
||||
log.add(methodCall);
|
||||
switch (methodCall.method) {
|
||||
case 'getPlatformName':
|
||||
return kPlatformName;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('can be registered', () {
|
||||
{{project_name.pascalCase()}}Linux.registerWith();
|
||||
expect({{project_name.pascalCase()}}Platform.instance, isA<{{project_name.pascalCase()}}Linux>());
|
||||
});
|
||||
|
||||
test('getPlatformName returns correct name', () async {
|
||||
final name = await {{project_name.camelCase()}}.getPlatformName();
|
||||
expect(
|
||||
log,
|
||||
<Matcher>[isMethodCall('getPlatformName', arguments: null)],
|
||||
);
|
||||
expect(name, equals(kPlatformName));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user