Skip to content

Commit 594d7f0

Browse files
committed
Add some tests for currentSexpRange
1 parent a0de331 commit 594d7f0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/extension-test/unit/cursor-doc/paredit-test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,35 @@ describe('paredit', () => {
14931493
});
14941494
});
14951495

1496+
describe('currentSexpsRange', () => {
1497+
const docSelectionCursorPosition = (positionNotation: string, rangeNotation: string) => {
1498+
const positionDoc = docFromTextNotation(positionNotation);
1499+
const rangeDoc = docFromTextNotation(rangeNotation);
1500+
const [_text1, positionSelection] = textAndSelection(positionDoc);
1501+
const position = positionSelection[0];
1502+
const [_text2, selection] = textAndSelection(rangeDoc);
1503+
const cursor = positionDoc.getTokenCursor(position);
1504+
return { doc: positionDoc, selection: selection, cursor, position };
1505+
};
1506+
1507+
it('Finds range with cursor between ignore marker and form, separated by whitespace before', () => {
1508+
const { doc, selection, cursor, position } = docSelectionCursorPosition(
1509+
'#_ |(:a b)',
1510+
'#_ |(:a b)|'
1511+
);
1512+
const range = paredit.currentSexpsRange(doc, cursor, position, false);
1513+
expect(range).toStrictEqual(selection);
1514+
});
1515+
it('Finds range with cursor between ignore marker and form, no whitespace', () => {
1516+
const { doc, selection, cursor, position } = docSelectionCursorPosition(
1517+
'#_|(:a b)',
1518+
'#_|(:a b)|'
1519+
);
1520+
const range = paredit.currentSexpsRange(doc, cursor, position, false);
1521+
expect(range).toStrictEqual(selection);
1522+
});
1523+
});
1524+
14961525
describe('backwardUp - one line', () => {
14971526
it('Drags up from start of vector', async () => {
14981527
const b = docFromTextNotation(`(def foo [:|foo :bar :baz])`);

0 commit comments

Comments
 (0)