|
1 | 1 | import * as assert from 'assert';
|
2 | 2 | import * as vscode from 'vscode';
|
3 | 3 |
|
| 4 | +import { createFile, clearDirectory, getLastMessage } from './common'; |
| 5 | + |
4 | 6 | suite('Extension Test Suite', () => {
|
5 |
| - vscode.window.showInformationMessage('Start all tests.'); |
| 7 | + const { workspaceFolders } = vscode.workspace; |
| 8 | + const directoryPath = workspaceFolders ? workspaceFolders[0].uri.fsPath : ''; |
| 9 | + |
| 10 | + suiteTeardown(() => clearDirectory(directoryPath)); |
| 11 | + |
| 12 | + test('should commit with "chore" type', async () => { |
| 13 | + const sampleSubject = 'add new file'; |
| 14 | + const expectedMessage = `chore: ${sampleSubject}`; |
| 15 | + |
| 16 | + await createFile(directoryPath, 'Hello World'); |
| 17 | + await vscode.env.clipboard.writeText(sampleSubject); |
| 18 | + await vscode.commands.executeCommand('gitSemanticCommit.semanticCommit'); |
| 19 | + await vscode.commands.executeCommand('editor.action.clipboardPasteAction'); |
| 20 | + await vscode.commands.executeCommand('workbench.action.quickOpenSelectNext'); |
| 21 | + await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem'); |
| 22 | + await new Promise(resolve => setTimeout(resolve, 3000)); |
| 23 | + const { stdout: message } = await getLastMessage(directoryPath); |
6 | 24 |
|
7 |
| - test('Sample test', () => { |
8 |
| - assert.equal(-1, [1, 2, 3].indexOf(5)); |
9 |
| - assert.equal(-1, [1, 2, 3].indexOf(0)); |
| 25 | + assert.equal(message.includes(expectedMessage), true); |
10 | 26 | });
|
11 | 27 | });
|
0 commit comments