mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test: added test to verify correct ordering after replacement of multiline text-nodes
This commit is contained in:
parent
3039f0427f
commit
8cc3eb4846
@ -155,15 +155,52 @@ void main() async {
|
|||||||
editor.editorState.apply(transaction);
|
editor.editorState.apply(transaction);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(editor.documentLength, 4);
|
expect(editor.documentLength, 4);
|
||||||
textNodes = [0, 1, 2, 3]
|
textNodes = [0, 1, 2, 3]
|
||||||
.map((e) => editor.nodeAtPath([e])!)
|
.map((e) => editor.nodeAtPath([e])!)
|
||||||
.whereType<TextNode>()
|
.whereType<TextNode>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
expect(textNodes[0].toPlainText(), '0123ABC');
|
expect(textNodes[0].toPlainText(), '0123ABC');
|
||||||
expect(textNodes[1].toPlainText(), 'ABC');
|
expect(textNodes[1].toPlainText(), 'ABC');
|
||||||
expect(textNodes[2].toPlainText(), 'ABC');
|
expect(textNodes[2].toPlainText(), 'ABC');
|
||||||
expect(textNodes[3].toPlainText(), 'ABC456789');
|
expect(textNodes[3].toPlainText(), 'ABC456789');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('test replaceTexts, textNodes.length << texts.length',
|
||||||
|
(tester) async {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
final editor = tester.editor
|
||||||
|
..insertTextNode('some text');
|
||||||
|
await editor.startTesting();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(editor.documentLength, 1);
|
||||||
|
|
||||||
|
final selection = Selection(
|
||||||
|
start: Position(path: [0], offset:0),
|
||||||
|
end: Position(path: [0], offset: 9),
|
||||||
|
);
|
||||||
|
final transaction = editor.editorState.transaction;
|
||||||
|
var textNodes = [0]
|
||||||
|
.map((e) => editor.nodeAtPath([e])!)
|
||||||
|
.whereType<TextNode>()
|
||||||
|
.toList(growable: false);
|
||||||
|
final texts = ['ABC1', 'ABC2', 'ABC3', 'ABC4','ABC5'];
|
||||||
|
transaction.replaceTexts(textNodes, selection, texts);
|
||||||
|
editor.editorState.apply(transaction);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(editor.documentLength, 5);
|
||||||
|
textNodes = [0, 1, 2, 3,4]
|
||||||
|
.map((e) => editor.nodeAtPath([e])!)
|
||||||
|
.whereType<TextNode>()
|
||||||
|
.toList(growable: false);
|
||||||
|
expect(textNodes[0].toPlainText(), 'ABC1');
|
||||||
|
expect(textNodes[1].toPlainText(), 'ABC2');
|
||||||
|
expect(textNodes[2].toPlainText(), 'ABC3');
|
||||||
|
expect(textNodes[3].toPlainText(), 'ABC4');
|
||||||
|
expect(textNodes[4].toPlainText(), 'ABC5');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user