feat: add document rules (#1071)
This commit is contained in:
parent
a583d139d2
commit
f2685cb900
1 changed files with 120 additions and 0 deletions
31
test/core/rules/at_least_one_editable_node_rule_test.dart
Normal file
31
test/core/rules/at_least_one_editable_node_rule_test.dart
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('at least one editable node rule', () async {
|
||||
final rule = AtLeastOneEditableNodeRule();
|
||||
final node1 = paragraphNode(text: 'Hello World!');
|
||||
final node2 = paragraphNode(text: 'Hello World!');
|
||||
final node3 = paragraphNode(text: 'Hello World!');
|
||||
final document = Document(
|
||||
root: pageNode(
|
||||
children: [
|
||||
node1,
|
||||
node2,
|
||||
node3,
|
||||
],
|
||||
),
|
||||
);
|
||||
final editorState = EditorState(document: document)..documentRules = [rule];
|
||||
// delete all the nodes
|
||||
final transaction = editorState.transaction;
|
||||
transaction.deleteNodes([node1, node2, node3]);
|
||||
await editorState.apply(transaction);
|
||||
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
final node = editorState.document.root.children[0];
|
||||
expect(node.type, ParagraphBlockKeys.type);
|
||||
|
||||
editorState.dispose();
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue