Skip to content

Commit 3d28d49

Browse files
committed
test: add assert for message type
1 parent 830b9eb commit 3d28d49

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/test/suite/extension.test.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
import * as assert from 'assert';
22
import * as vscode from 'vscode';
33

4+
import { createFile, clearDirectory, getLastMessage } from './common';
5+
46
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);
624

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);
1026
});
1127
});

0 commit comments

Comments
 (0)