mirror of
https://github.com/AppFlowy-IO/AppFlowy
synced 2026-05-24 09:38:25 +00:00
test: node tests
This commit is contained in:
parent
eaf396630c
commit
bfe61ea09d
1 changed files with 35 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:collection';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart';
|
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 {}
|
class MockNode extends Mock implements Node {}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('NodeExtensions::', () {
|
final mockNode = MockNode();
|
||||||
final mockNode = MockNode();
|
|
||||||
|
|
||||||
|
group('NodeExtensions::', () {
|
||||||
final selection = Selection(
|
final selection = Selection(
|
||||||
start: Position(path: [0, 1]),
|
start: Position(path: [0]),
|
||||||
end: Position(path: [1, 0]),
|
end: Position(path: [1]),
|
||||||
);
|
);
|
||||||
|
|
||||||
test('rect - renderBox is null', () {
|
test('rect - renderBox is null', () {
|
||||||
|
|
@ -22,10 +23,35 @@ void main() {
|
||||||
expect(result, Rect.zero);
|
expect(result, Rect.zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test('inSelection', () {
|
test('inSelection', () {
|
||||||
// when(mockNode.path).thenAnswer((_) => [3, 3]);
|
// I use an empty implementation instead of mock, because the mocked
|
||||||
// final result = mockNode.inSelection(selection);
|
// version throws error trying to access the path.
|
||||||
// expect(result, true);
|
|
||||||
// });
|
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…
Reference in a new issue