Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
import * as assert from 'assert';
import * as vscode from 'vscode';
import * as assert from "assert";
import * as vscode from "vscode";

import { createFile, clearDirectory, getLastMessage } from './common';
import { createFile, clearDirectory, getLastMessage } from "./common";

suite('Extension Test Suite', () => {
suite("Extension Test Suite", () => {
const { workspaceFolders } = vscode.workspace;
const directoryPath = workspaceFolders ? workspaceFolders[0].uri.fsPath : '';
const directoryPath = workspaceFolders ? workspaceFolders[0].uri.fsPath : "";

suiteTeardown(() => clearDirectory(directoryPath));

test('should commit with "chore" type', async () => {
const sampleSubject = 'add new file';
const expectedMessage = `chore: ${sampleSubject}`;
const sampleSubject = "add new file";
const expectedMessage = `build: ${sampleSubject}`;

await createFile(directoryPath, 'Hello World');
await createFile(directoryPath, "Hello World");
await vscode.env.clipboard.writeText(sampleSubject);
await vscode.commands.executeCommand('gitSemanticCommit.semanticCommit');
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
await vscode.commands.executeCommand('workbench.action.quickOpenSelectNext');
await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
await vscode.commands.executeCommand("gitSemanticCommit.semanticCommit");
await vscode.commands.executeCommand("editor.action.clipboardPasteAction");
await vscode.commands.executeCommand(
"workbench.action.quickOpenSelectNext"
);
await vscode.commands.executeCommand(
"workbench.action.acceptSelectedQuickOpenItem"
);
await new Promise(resolve => setTimeout(resolve, 3000));
const { stdout: message } = await getLastMessage(directoryPath);

assert.equal(message.includes(expectedMessage), true);
});

test('should commit with a scope and "chore" type', async () => {
const sampleScope = 'scope';
const sampleSubject = 'add new file';
const expectedMessage = `chore(${sampleScope}): ${sampleSubject}`;
const sampleScope = "scope";
const sampleSubject = "add new file";
const expectedMessage = `build(${sampleScope}): ${sampleSubject}`;

await createFile(directoryPath, 'Hello World');
await createFile(directoryPath, "Hello World");
await vscode.env.clipboard.writeText(sampleScope);
await vscode.commands.executeCommand('gitSemanticCommit.semanticCommit');
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
await vscode.commands.executeCommand("gitSemanticCommit.semanticCommit");
await vscode.commands.executeCommand("editor.action.clipboardPasteAction");
await vscode.commands.executeCommand(
"workbench.action.acceptSelectedQuickOpenItem"
);
await vscode.env.clipboard.writeText(sampleSubject);
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
await vscode.commands.executeCommand('workbench.action.quickOpenSelectNext');
await vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem');
await vscode.commands.executeCommand("editor.action.clipboardPasteAction");
await vscode.commands.executeCommand(
"workbench.action.quickOpenSelectNext"
);
await vscode.commands.executeCommand(
"workbench.action.acceptSelectedQuickOpenItem"
);
await new Promise(resolve => setTimeout(resolve, 3000));
const { stdout: message } = await getLastMessage(directoryPath);

Expand Down