appflowy-editor/test/extensions/node_extension_test.dart

60 lines
1.3 KiB
Dart
Raw Normal View History

2022-10-04 22:39:55 -05:00
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
2023-03-09 14:38:54 +07:00
group('node_extension.dart', () {
2022-10-04 22:39:55 -05:00
final selection = Selection(
2022-10-05 23:46:34 -05:00
start: Position(path: [0]),
end: Position(path: [1]),
2022-10-04 22:39:55 -05:00
);
2022-10-05 23:46:34 -05:00
test('inSelection', () {
// I use an empty implementation instead of mock, because the mocked
// version throws error trying to access the path.
2023-05-04 10:05:06 +08:00
final subNodes = [
Node(type: 'type'),
Node(type: 'type'),
Node(type: 'type'),
Node(type: 'type'),
Node(type: 'type'),
];
final nodes = [
Node(
type: 'type',
children: subNodes,
),
];
2022-10-05 23:46:34 -05:00
final node = Node(
type: 'type',
2023-05-04 10:05:06 +08:00
children: nodes,
2022-10-05 23:46:34 -05:00
attributes: {},
);
final result = node.inSelection(selection);
expect(result, false);
});
2023-03-09 14:38:54 +07:00
2023-03-24 13:59:03 +01:00
test('inSelection w/ Reverse selection', () {
2023-05-04 10:05:06 +08:00
final subNodes = [
Node(
type: 'type',
2023-09-13 15:26:29 +08:00
),
2023-05-04 10:05:06 +08:00
];
2023-03-24 13:59:03 +01:00
final node = Node(
type: 'type',
2023-05-04 10:05:06 +08:00
children: subNodes,
2023-03-24 13:59:03 +01:00
);
final reverseSelection = Selection(
start: Position(path: [1]),
end: Position(path: [0]),
);
final result = node.inSelection(reverseSelection);
expect(result, false);
});
2022-10-04 22:39:55 -05:00
});
}