-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create executeCommandWithPrefixArgument command
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/test/suite/execute-command-with-prefix-argument.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import * as vscode from "vscode"; | ||
import sinon from "sinon"; | ||
import assert from "assert"; | ||
import { EmacsEmulator } from "../../emulator"; | ||
import { cleanUpWorkspace, setupWorkspace } from "./utils"; | ||
|
||
suite("executeCommandWithPrefixArgument", () => { | ||
let commandMock: sinon.SinonExpectation; | ||
let commandDisposable: vscode.Disposable; | ||
|
||
let activeTextEditor: vscode.TextEditor; | ||
let emulator: EmacsEmulator; | ||
|
||
setup(async () => { | ||
commandMock = sinon.mock(); | ||
commandDisposable = vscode.commands.registerCommand("emacs-mcx-test.foo", commandMock); | ||
|
||
activeTextEditor = await setupWorkspace(); | ||
emulator = new EmacsEmulator(activeTextEditor); | ||
}); | ||
|
||
teardown(async () => { | ||
commandDisposable.dispose(); | ||
await cleanUpWorkspace(); | ||
}); | ||
|
||
test("executing another command", async () => { | ||
await emulator.executeCommandWithPrefixArgument("emacs-mcx-test.foo"); | ||
|
||
assert.ok(commandMock.calledWith({ prefixArgument: undefined })); | ||
}); | ||
|
||
test("executing another command with the prefix argument", async () => { | ||
await emulator.universalArgument(); | ||
|
||
await emulator.executeCommandWithPrefixArgument("emacs-mcx-test.foo"); | ||
|
||
assert.ok(commandMock.calledWith({ prefixArgument: 4 })); | ||
}); | ||
|
||
test("executing another command with arguments", async () => { | ||
await emulator.executeCommandWithPrefixArgument("emacs-mcx-test.foo", { foo: "bar", baz: 42 }); | ||
|
||
assert.ok(commandMock.calledWith({ foo: "bar", baz: 42, prefixArgument: undefined })); | ||
}); | ||
|
||
test("executing another command with the passed arguments and the prefix argument", async () => { | ||
await emulator.universalArgument(); | ||
|
||
await emulator.executeCommandWithPrefixArgument("emacs-mcx-test.foo", { foo: "bar", baz: 42 }); | ||
|
||
assert.ok(commandMock.calledWith({ foo: "bar", baz: 42, prefixArgument: 4 })); | ||
}); | ||
|
||
test("executing another command with the customized prefix argument key", async () => { | ||
await emulator.universalArgument(); | ||
|
||
await emulator.executeCommandWithPrefixArgument("emacs-mcx-test.foo", {}, "repeat"); | ||
|
||
assert.ok(commandMock.calledWith({ repeat: 4 })); | ||
}); | ||
}); |