appflowy-editor/test/service/editor_service_test.dart

56 lines
1.7 KiB
Dart
Raw Normal View History

import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';
2023-09-11 15:03:14 +08:00
import 'package:flutter_test/flutter_test.dart';
2023-05-02 23:01:48 +08:00
import '../new/infra/testable_editor.dart';
void main() {
group('AppFlowyEditor tests', () {
testWidgets('without autoFocus false', (tester) async {
2023-05-02 23:01:48 +08:00
final editor = tester.editor..addParagraph(initialText: 'Hello');
await editor.startTesting();
2023-05-02 23:01:48 +08:00
final selection = editor.selection;
expect(selection != null, false);
await editor.dispose();
});
testWidgets('with autoFocus true', (tester) async {
2023-05-02 23:01:48 +08:00
final editor = tester.editor..addParagraph(initialText: 'Hello');
await editor.startTesting(autoFocus: true);
final selection = editor.selection;
expect(selection != null, true);
await editor.dispose();
});
testWidgets('with shrinkWrap false', (tester) async {
final editor = tester.editor
..addParagraphs(
1000,
initialText: 'Hello',
);
await editor.startTesting();
final size = tester.getSize(find.byType(AppFlowyEditor));
2023-07-04 11:22:35 +08:00
expect(size, const Size(800, 600));
await editor.dispose();
});
testWidgets('with shrinkWrap true and wrapper with scroll view',
(tester) async {
final editor = tester.editor
..addParagraphs(
1000,
initialText: 'Hello',
);
await editor.startTesting(
shrinkWrap: true,
wrapper: (child) => SingleChildScrollView(
child: IntrinsicHeight(
child: child,
),
),
);
final size = tester.getSize(find.byType(AppFlowyEditor));
expect(size.height > 1000, true);
});
});
}