mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
test: node tests
This commit is contained in:
parent
eaf396630c
commit
bfe61ea09d
@ -1,3 +1,4 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
@ -8,12 +9,12 @@ import 'package:appflowy_editor/src/extensions/node_extensions.dart';
|
||||
class MockNode extends Mock implements Node {}
|
||||
|
||||
void main() {
|
||||
group('NodeExtensions::', () {
|
||||
final mockNode = MockNode();
|
||||
final mockNode = MockNode();
|
||||
|
||||
group('NodeExtensions::', () {
|
||||
final selection = Selection(
|
||||
start: Position(path: [0, 1]),
|
||||
end: Position(path: [1, 0]),
|
||||
start: Position(path: [0]),
|
||||
end: Position(path: [1]),
|
||||
);
|
||||
|
||||
test('rect - renderBox is null', () {
|
||||
@ -22,10 +23,35 @@ void main() {
|
||||
expect(result, Rect.zero);
|
||||
});
|
||||
|
||||
// test('inSelection', () {
|
||||
// when(mockNode.path).thenAnswer((_) => [3, 3]);
|
||||
// final result = mockNode.inSelection(selection);
|
||||
// expect(result, true);
|
||||
// });
|
||||
test('inSelection', () {
|
||||
// I use an empty implementation instead of mock, because the mocked
|
||||
// version throws error trying to access the path.
|
||||
|
||||
final subLinkedList = LinkedList<Node>()
|
||||
..addAll([
|
||||
Node(type: 'type', children: LinkedList(), attributes: {}),
|
||||
Node(type: 'type', children: LinkedList(), attributes: {}),
|
||||
Node(type: 'type', children: LinkedList(), attributes: {}),
|
||||
Node(type: 'type', children: LinkedList(), attributes: {}),
|
||||
Node(type: 'type', children: LinkedList(), attributes: {}),
|
||||
]);
|
||||
|
||||
final linkedList = LinkedList<Node>()
|
||||
..addAll([
|
||||
Node(
|
||||
type: 'type',
|
||||
children: subLinkedList,
|
||||
attributes: {},
|
||||
),
|
||||
]);
|
||||
|
||||
final node = Node(
|
||||
type: 'type',
|
||||
children: linkedList,
|
||||
attributes: {},
|
||||
);
|
||||
final result = node.inSelection(selection);
|
||||
expect(result, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user