mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-19 03:54:28 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Todo: fda71ed1 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:google_account_token/google_account_token.dart'
|
|
show kGoogleAccountTokenChannel;
|
|
import 'package:todo/sync/google_sign_in_backend.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
final messenger =
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
|
MethodCall? seen;
|
|
|
|
void fakeChannel(Future<Object?> Function(MethodCall) handler) {
|
|
messenger.setMockMethodCallHandler(kGoogleAccountTokenChannel, (call) {
|
|
seen = call;
|
|
return handler(call);
|
|
});
|
|
}
|
|
|
|
setUp(() => debugDefaultTargetPlatformOverride = TargetPlatform.android);
|
|
|
|
tearDown(() {
|
|
debugDefaultTargetPlatformOverride = null;
|
|
seen = null;
|
|
messenger.setMockMethodCallHandler(kGoogleAccountTokenChannel, null);
|
|
});
|
|
|
|
group('googleIdToken', () {
|
|
test('goes through the shared plugin channel by default', () async {
|
|
fakeChannel((_) async => 'jwt-2');
|
|
expect(await googleIdToken(), 'jwt-2');
|
|
expect(seen?.method, 'idToken');
|
|
expect(seen?.arguments, {'serverClientId': kServerClientId});
|
|
});
|
|
|
|
test('a cancelled chooser is null, not an error', () async {
|
|
fakeChannel((_) async => null);
|
|
expect(await googleIdToken(), isNull);
|
|
});
|
|
});
|
|
|
|
test('sign-in comes from the shared plugin, not a local copy', () {
|
|
final pubspec = File('pubspec.yaml').readAsStringSync();
|
|
expect(pubspec, contains('google_account_token-v0.1.0'));
|
|
expect(pubspec, isNot(contains('google_sign_in')));
|
|
expect(
|
|
File(
|
|
'android/app/src/main/kotlin/dev/kuhy/todo/AccountTokenChannel.kt',
|
|
).existsSync(),
|
|
isFalse,
|
|
);
|
|
expect(File('lib/sync/account_token.dart').existsSync(), isFalse);
|
|
});
|
|
}
|