mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-03 15:11:43 +00:00
58 lines
1.9 KiB
Dart
58 lines
1.9 KiB
Dart
![]() |
import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';
|
||
|
import 'package:appflowy/startup/tasks/deeplink/invitation_deeplink_handler.dart';
|
||
|
import 'package:appflowy/startup/tasks/deeplink/login_deeplink_handler.dart';
|
||
|
import 'package:appflowy/startup/tasks/deeplink/payment_deeplink_handler.dart';
|
||
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
|
||
|
void main() {
|
||
|
group('deep link handler: ', () {
|
||
|
final deepLinkHandlerRegistry = DeepLinkHandlerRegistry.instance
|
||
|
..register(LoginDeepLinkHandler())
|
||
|
..register(PaymentDeepLinkHandler())
|
||
|
..register(InvitationDeepLinkHandler());
|
||
|
|
||
|
test('invitation deep link handler', () {
|
||
|
final uri = Uri.parse(
|
||
|
'appflowy-flutter://invitation-callback?email=lucas@appflowy.com&workspace_id=123',
|
||
|
);
|
||
|
deepLinkHandlerRegistry.processDeepLink(
|
||
|
uri: uri,
|
||
|
onStateChange: (handler, state) {
|
||
|
expect(handler, isA<InvitationDeepLinkHandler>());
|
||
|
},
|
||
|
onResult: (handler, result) {
|
||
|
expect(handler, isA<InvitationDeepLinkHandler>());
|
||
|
expect(result.isSuccess, true);
|
||
|
},
|
||
|
onError: (error) {
|
||
|
expect(error, isNull);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
|
|
||
|
test('login deep link handler', () {
|
||
|
final uri =
|
||
|
Uri.parse('appflowy-flutter://login-callback#access_token=123');
|
||
|
expect(LoginDeepLinkHandler().canHandle(uri), true);
|
||
|
});
|
||
|
|
||
|
test('payment deep link handler', () {
|
||
|
final uri = Uri.parse('appflowy-flutter://payment-success');
|
||
|
expect(PaymentDeepLinkHandler().canHandle(uri), true);
|
||
|
});
|
||
|
|
||
|
test('unknown deep link handler', () {
|
||
|
final uri =
|
||
|
Uri.parse('appflowy-flutter://unknown-callback?workspace_id=123');
|
||
|
deepLinkHandlerRegistry.processDeepLink(
|
||
|
uri: uri,
|
||
|
onStateChange: (handler, state) {},
|
||
|
onResult: (handler, result) {},
|
||
|
onError: (error) {
|
||
|
expect(error, isNotNull);
|
||
|
},
|
||
|
);
|
||
|
});
|
||
|
});
|
||
|
}
|