-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathtextLine.vscode.test.ts
More file actions
28 lines (25 loc) · 894 Bytes
/
textLine.vscode.test.ts
File metadata and controls
28 lines (25 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as assert from "node:assert/strict";
import { getReusableEditor } from "@cursorless/lib-vscode-common";
import VscodeTextLine from "./VscodeTextLine";
/**
* Each test is of the form:
*
* `[text, firstNonWhitespaceCharacterIndex, lastNonWhitespaceCharacterIndex]`
*/
const whiteSpaceTests: [string, number | undefined, number | undefined][] = [
[" ", undefined, undefined],
["foo", 0, 3],
[" foo ", 1, 4],
];
suite("TextLine", function () {
this.timeout("100s");
this.retries(5);
whiteSpaceTests.forEach(([text, trimmedStart, trimmedEnd]) => {
test(`whitespace '${text}'`, async () => {
const editor = await getReusableEditor(text);
const line = new VscodeTextLine(editor.document.lineAt(0));
assert.equal(line.rangeTrimmed?.start?.character, trimmedStart);
assert.equal(line.rangeTrimmed?.end?.character, trimmedEnd);
});
});
});