diff --git a/autologin_linux/test/autologin_linux_test.dart b/autologin_linux/test/autologin_linux_test.dart index 48e2393..5752b05 100644 --- a/autologin_linux/test/autologin_linux_test.dart +++ b/autologin_linux/test/autologin_linux_test.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:autologin_linux/autologin_linux.dart'; import 'package:autologin_platform_interface/autologin_platform_interface.dart'; import 'package:flutter/services.dart'; @@ -7,9 +9,10 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('AutologinLinux', () { - const kPlatformName = 'Linux'; late AutologinLinux autologin; late List log; + const expectedCompatibilities = Compatibilities(isPlatformSupported: true); + const expectedCredentials = Credential(username: 'foo', password: 'bar'); setUp(() async { autologin = AutologinLinux(); @@ -19,8 +22,12 @@ void main() { .setMockMethodCallHandler(autologin.methodChannel, (methodCall) async { log.add(methodCall); switch (methodCall.method) { - case 'getPlatformName': - return kPlatformName; + case 'performCompatibilityChecks': + return jsonEncode(expectedCompatibilities.toJson()); + case 'requestCredentials': + return jsonEncode(expectedCredentials.toJson()); + case 'saveCredentials': + return 'true'; default: return null; } @@ -32,13 +39,49 @@ void main() { expect(AutologinPlatform.instance, isA()); }); - test('getPlatformName returns correct name', () async { - final name = await autologin.getPlatformName(); + test('performCompatibilityChecks returns expected value', () async { + final report = await autologin.performCompatibilityChecks(); + expect( + log, + [isMethodCall('performCompatibilityChecks', arguments: null)], + ); + expect(report, equals(expectedCompatibilities)); + }); + + test('requestCredentials returns expected value', () async { + final credentials = await autologin.requestCredentials(); + expect( + log, + [isMethodCall('requestCredentials', arguments: null)], + ); + expect(credentials, equals(expectedCredentials)); + }); + + test('saveCredentials returns expected value', () async { + final report = await autologin.saveCredentials(expectedCredentials); + expect( + log, + [isMethodCall('saveCredentials', arguments: expectedCredentials.toJson())], + ); + expect(report, equals(true)); + }); + + test('requestLoginToken returns nothing', () async { + final token = await autologin.requestLoginToken(); + expect( + log, + [isMethodCall('requestLoginToken', arguments: null)], + ); + expect(token, equals(null)); + }); + + test('saveLoginToken returns expected value', () async { + final report = await autologin.saveLoginToken(expectedToken); expect( log, - [isMethodCall('getPlatformName', arguments: null)], + [isMethodCall('saveLoginToken', arguments: expectedToken)], ); - expect(name, equals(kPlatformName)); + expect(report, equals(false)); }); }); }