Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amantoux committed Aug 12, 2024
1 parent 9d1ee4b commit 4bdf00a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/fleather/test/widgets/editor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,35 @@ void main() {
expect(sentData?.delta, Delta()..insert('t T'));
});

testWidgets(
'Copy sends correct data to clipboard manager when selection extents are inverted',
(tester) async {
prepareClipboard();
FleatherClipboardData? sentData;
final editor = EditorSandBox(
tester: tester,
document: ParchmentDocument.fromJson([
{'insert': 'Test Text\n'}
]),
autofocus: true,
clipboardManager: FleatherCustomClipboardManager(
getData: () => throw UnimplementedError(),
setData: (data) async => sentData = data,
),
);
await editor.pump();
final RawEditorState state =
tester.state<RawEditorState>(find.byType(RawEditor));
await editor.updateSelection(base: 6, extent: 3);
state.showToolbar(createIfNull: true);
await tester.pump();
final finder = find.text('Copy');
await tester.tap(finder);
await tester.pumpAndSettle(throttleDuration);
expect(sentData?.plainText, 't T');
expect(sentData?.delta, Delta()..insert('t T'));
});

testWidgets('Cut intent sends data to clipboard manager', (tester) async {
prepareClipboard();
FleatherClipboardData? sentData;
Expand Down

0 comments on commit 4bdf00a

Please sign in to comment.