Browse Source

Add tests for custom word separators

xuty 3 năm trước cách đây
mục cha
commit
e39c901d91
2 tập tin đã thay đổi với 46 bổ sung0 xóa
  1. 18 0
      test/src/core/buffer/buffer_test.dart
  2. 28 0
      test/src/terminal_test.dart

+ 18 - 0
test/src/core/buffer/buffer_test.dart

@@ -138,6 +138,24 @@ void main() {
     });
   });
 
+  group('Buffer.getWordBoundary supports custom word separators', () {
+    test('can set word separators', () {
+      final terminal = Terminal(wordSeparators: {'o'.codeUnitAt(0)});
+
+      terminal.write('Hello World');
+
+      expect(
+        terminal.mainBuffer.getWordBoundary(CellOffset(0, 0)),
+        BufferRangeLine(CellOffset(0, 0), CellOffset(4, 0)),
+      );
+
+      expect(
+        terminal.mainBuffer.getWordBoundary(CellOffset(5, 0)),
+        BufferRangeLine(CellOffset(5, 0), CellOffset(7, 0)),
+      );
+    });
+  });
+
   test('does not delete lines beyond the scroll region', () {
     final terminal = Terminal();
     terminal.resize(10, 10);

+ 28 - 0
test/src/terminal_test.dart

@@ -85,6 +85,34 @@ void main() {
       expect(terminal.buffer.lines[2].toString(), 'd');
     });
   });
+
+  group('Terminal.mouseInput', () {
+    test('applys to the main buffer', () {
+      final terminal = Terminal(
+        wordSeparators: {
+          'z'.codeUnitAt(0),
+        },
+      );
+
+      expect(
+        terminal.mainBuffer.wordSeparators,
+        contains('z'.codeUnitAt(0)),
+      );
+    });
+
+    test('applys to the alternate buffer', () {
+      final terminal = Terminal(
+        wordSeparators: {
+          'z'.codeUnitAt(0),
+        },
+      );
+
+      expect(
+        terminal.altBuffer.wordSeparators,
+        contains('z'.codeUnitAt(0)),
+      );
+    });
+  });
 }
 
 class _TestInputHandler implements TerminalInputHandler {