(file: string)
| 50 | }); |
| 51 | |
| 52 | async function runTest(file: string) { |
| 53 | const buffer = await fsp.readFile(file); |
| 54 | const fixture = yaml.load(buffer.toString()) as TestCaseFixture; |
| 55 | const excludeFields: string[] = []; |
| 56 | |
| 57 | const cursorlessApi = await getCursorlessApi(); |
| 58 | const graph = cursorlessApi.graph!; |
| 59 | |
| 60 | const editor = await openNewEditor( |
| 61 | fixture.initialState.documentContents, |
| 62 | fixture.languageId |
| 63 | ); |
| 64 | |
| 65 | if (!fixture.initialState.documentContents.includes("\n")) { |
| 66 | await editor.edit((editBuilder) => { |
| 67 | editBuilder.setEndOfLine(vscode.EndOfLine.LF); |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | editor.selections = fixture.initialState.selections.map(createSelection); |
| 72 | |
| 73 | if (fixture.initialState.thatMark) { |
| 74 | const initialThatMark = fixture.initialState.thatMark.map((mark) => ({ |
| 75 | selection: createSelection(mark), |
| 76 | editor, |
| 77 | })); |
| 78 | cursorlessApi.thatMark.set(initialThatMark); |
| 79 | } |
| 80 | if (fixture.initialState.sourceMark) { |
| 81 | const initialSourceMark = fixture.initialState.sourceMark.map((mark) => ({ |
| 82 | selection: createSelection(mark), |
| 83 | editor, |
| 84 | })); |
| 85 | cursorlessApi.sourceMark.set(initialSourceMark); |
| 86 | } |
| 87 | |
| 88 | if (fixture.initialState.clipboard) { |
| 89 | let mockClipboard = fixture.initialState.clipboard; |
| 90 | sinon.replace(Clipboard, "readText", async () => mockClipboard); |
| 91 | sinon.replace(Clipboard, "writeText", async (value: string) => { |
| 92 | mockClipboard = value; |
| 93 | }); |
| 94 | } else { |
| 95 | excludeFields.push("clipboard"); |
| 96 | } |
| 97 | |
| 98 | await graph.hatTokenMap.addDecorations(); |
| 99 | |
| 100 | const readableHatMap = await graph.hatTokenMap.getReadableMap(false); |
| 101 | |
| 102 | // Assert that recorded decorations are present |
| 103 | checkMarks(fixture.initialState.marks, readableHatMap); |
| 104 | |
| 105 | const returnValue = await vscode.commands.executeCommand( |
| 106 | "cursorless.command", |
| 107 | fixture.command |
| 108 | ); |
| 109 |
no test coverage detected