Skip to content

Commit

Permalink
test: move 'clean' test into 'Clean' suite
Browse files Browse the repository at this point in the history
  • Loading branch information
senyai committed May 28, 2023
1 parent 0775a93 commit ae684c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
3 changes: 0 additions & 3 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
fossil_branch_suite,
fossil_change_branch_to_hash,
fossil_change_branch_to_trunk,
fossil_clean,
fossil_close,
fossil_commit_suite,
fossil_ignore,
Expand Down Expand Up @@ -154,8 +153,6 @@ suite('Fossil.OpenedRepo', function () {
test('fossil change branch to hash', () =>
fossil_change_branch_to_hash(sandbox)).timeout(5000);

test('fossil clean', () => fossil_clean(sandbox)).timeout(5000);

fossil_stash_suite(sandbox);
fossil_branch_suite(sandbox);
fossil_commit_suite(sandbox);
Expand Down
39 changes: 18 additions & 21 deletions src/test/suite/test_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,27 +452,6 @@ export async function fossil_change_branch_to_hash(
assert.ok(updateCall.calledOnce);
}

export async function fossil_clean(sandbox: sinon.SinonSandbox): Promise<void> {
const showWarningMessage: sinon.SinonStub = sandbox.stub(
vscode.window,
'showWarningMessage'
);
showWarningMessage.onFirstCall().resolves('&&Delete Extras');

const repository = getRepository();
const openedRepository: OpenedRepository = (repository as any).repository;
const execStub = sandbox.stub(openedRepository, 'exec').callThrough();
const tagCallStub = execStub.withArgs(['clean']);
await vscode.commands.executeCommand('fossil.clean');
sinon.assert.calledOnce(tagCallStub);
sinon.assert.calledOnceWithExactly(
showWarningMessage,
'Are you sure you want to delete untracked and unignored files?',
{ modal: true },
'&&Delete Extras'
);
}

export function fossil_stash_suite(sandbox: sinon.SinonSandbox): void {
suite('Stash', function (this: Suite) {
afterEach(() => {
Expand Down Expand Up @@ -1566,6 +1545,24 @@ export function fossil_rename_suite(sandbox: sinon.SinonSandbox): void {

export function fossil_clean_suite(sandbox: sinon.SinonSandbox): void {
suite('Clean', function (this: Suite) {
test('Clean', async () => {
const showWarningMessage: sinon.SinonStub = sandbox.stub(
vscode.window,
'showWarningMessage'
);
showWarningMessage.onFirstCall().resolves('&&Delete Extras');

const execStub = getExecStub(sandbox);
const cleanCallStub = execStub.withArgs(['clean']);
await vscode.commands.executeCommand('fossil.clean');
sinon.assert.calledOnce(cleanCallStub);
sinon.assert.calledOnceWithExactly(
showWarningMessage,
'Are you sure you want to delete untracked and unignored files?',
{ modal: true },
'&&Delete Extras'
);
}).timeout(5000);
test('Delete untracked files', async () => {
const repository = getRepository();
const execStub = getExecStub(sandbox);
Expand Down

0 comments on commit ae684c6

Please sign in to comment.