diff --git a/frontend/app_flowy/packages/appflowy_editor/test/extensions/node_extension_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/extensions/node_extension_test.dart index 7b0d106582..0e31aa5a96 100644 --- a/frontend/app_flowy/packages/appflowy_editor/test/extensions/node_extension_test.dart +++ b/frontend/app_flowy/packages/appflowy_editor/test/extensions/node_extension_test.dart @@ -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() + ..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() + ..addAll([ + Node( + type: 'type', + children: subLinkedList, + attributes: {}, + ), + ]); + + final node = Node( + type: 'type', + children: linkedList, + attributes: {}, + ); + final result = node.inSelection(selection); + expect(result, false); + }); }); }