Skip to content

Commit

Permalink
Add some tests for currentSexpRange
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Apr 22, 2024
1 parent a0de331 commit 594d7f0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/extension-test/unit/cursor-doc/paredit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,35 @@ describe('paredit', () => {
});
});

describe('currentSexpsRange', () => {
const docSelectionCursorPosition = (positionNotation: string, rangeNotation: string) => {
const positionDoc = docFromTextNotation(positionNotation);
const rangeDoc = docFromTextNotation(rangeNotation);
const [_text1, positionSelection] = textAndSelection(positionDoc);
const position = positionSelection[0];
const [_text2, selection] = textAndSelection(rangeDoc);
const cursor = positionDoc.getTokenCursor(position);
return { doc: positionDoc, selection: selection, cursor, position };
};

it('Finds range with cursor between ignore marker and form, separated by whitespace before', () => {
const { doc, selection, cursor, position } = docSelectionCursorPosition(
'#_ |(:a b)',
'#_ |(:a b)|'
);
const range = paredit.currentSexpsRange(doc, cursor, position, false);
expect(range).toStrictEqual(selection);
});
it('Finds range with cursor between ignore marker and form, no whitespace', () => {
const { doc, selection, cursor, position } = docSelectionCursorPosition(
'#_|(:a b)',
'#_|(:a b)|'
);
const range = paredit.currentSexpsRange(doc, cursor, position, false);
expect(range).toStrictEqual(selection);
});
});

describe('backwardUp - one line', () => {
it('Drags up from start of vector', async () => {
const b = docFromTextNotation(`(def foo [:|foo :bar :baz])`);
Expand Down

0 comments on commit 594d7f0

Please sign in to comment.