From 594d7f0748f28589ed8506685138bbf70d8a9548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Str=C3=B6mberg?= Date: Mon, 22 Apr 2024 23:08:21 +0200 Subject: [PATCH] Add some tests for currentSexpRange --- .../unit/cursor-doc/paredit-test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/extension-test/unit/cursor-doc/paredit-test.ts b/src/extension-test/unit/cursor-doc/paredit-test.ts index 7af754b69..5d1126dd3 100644 --- a/src/extension-test/unit/cursor-doc/paredit-test.ts +++ b/src/extension-test/unit/cursor-doc/paredit-test.ts @@ -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])`);