mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: add simple test for l10n
This commit is contained in:
@ -29,6 +29,9 @@ dev_dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.1
|
flutter_lints: ^2.0.1
|
||||||
network_image_mock: ^2.1.1
|
network_image_mock: ^2.1.1
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
# following page: https://dart.dev/tools/pub/pubspec
|
||||||
|
@ -3,6 +3,7 @@ import 'dart:collection';
|
|||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'test_raw_key_event.dart';
|
import 'test_raw_key_event.dart';
|
||||||
@ -22,12 +23,18 @@ class EditorWidgetTester {
|
|||||||
Selection? get documentSelection =>
|
Selection? get documentSelection =>
|
||||||
_editorState.service.selectionService.currentSelection.value;
|
_editorState.service.selectionService.currentSelection.value;
|
||||||
|
|
||||||
Future<EditorWidgetTester> startTesting() async {
|
Future<EditorWidgetTester> startTesting({
|
||||||
|
Locale locale = const Locale('en'),
|
||||||
|
}) async {
|
||||||
final app = MaterialApp(
|
final app = MaterialApp(
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalCupertinoLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
AppFlowyEditorLocalizations.delegate,
|
AppFlowyEditorLocalizations.delegate,
|
||||||
],
|
],
|
||||||
supportedLocales: AppFlowyEditorLocalizations.delegate.supportedLocales,
|
supportedLocales: AppFlowyEditorLocalizations.delegate.supportedLocales,
|
||||||
|
locale: locale,
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: AppFlowyEditor(
|
body: AppFlowyEditor(
|
||||||
editorState: _editorState,
|
editorState: _editorState,
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import '../infra/test_editor.dart';
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
setUpAll(() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
});
|
||||||
|
|
||||||
|
group('l10n.dart', () {
|
||||||
|
for (final locale
|
||||||
|
in AppFlowyEditorLocalizations.delegate.supportedLocales) {
|
||||||
|
testWidgets('test localization', (tester) async {
|
||||||
|
final editor = tester.editor..insertTextNode('');
|
||||||
|
await editor.startTesting(locale: locale);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user