mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-20 00:27:41 +03:00
Add test for comment operator
This commit is contained in:
parent
bd780205a2
commit
5a6d305e1c
@ -7,7 +7,9 @@ import { ModeHandler } from '../../src/mode/modeHandler';
|
||||
|
||||
suite("Mode Handler", () => {
|
||||
|
||||
setup(setupWorkspace);
|
||||
setup(async () => {
|
||||
await setupWorkspace();
|
||||
});
|
||||
|
||||
teardown(cleanUpWorkspace);
|
||||
|
||||
|
50
test/operator/comment.test.ts
Normal file
50
test/operator/comment.test.ts
Normal file
@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
import { setupWorkspace, setTextEditorOptions, cleanUpWorkspace } from './../testUtils';
|
||||
import { ModeName } from '../../src/mode/mode';
|
||||
import { ModeHandler } from '../../src/mode/modeHandler';
|
||||
import { getTestingFunctions } from '../testSimplifier';
|
||||
|
||||
suite("comment operator", () => {
|
||||
let modeHandler: ModeHandler;
|
||||
let {
|
||||
newTest,
|
||||
newTestOnly,
|
||||
} = getTestingFunctions();
|
||||
|
||||
setup(async () => {
|
||||
await setupWorkspace(".js");
|
||||
setTextEditorOptions(4, false);
|
||||
modeHandler = new ModeHandler();
|
||||
});
|
||||
|
||||
teardown(cleanUpWorkspace);
|
||||
|
||||
newTest({
|
||||
title: "gbb comments out current line",
|
||||
start: [
|
||||
"first| line",
|
||||
"second line"
|
||||
],
|
||||
keysPressed: 'gbb',
|
||||
end: [
|
||||
"|// first line",
|
||||
"second line",
|
||||
],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "gbj comments in current and next line",
|
||||
start: [
|
||||
"// first| line",
|
||||
"// second line",
|
||||
"third line"
|
||||
],
|
||||
keysPressed: 'gbj',
|
||||
end: [
|
||||
"|first line",
|
||||
"second line",
|
||||
"third line"
|
||||
],
|
||||
});
|
||||
});
|
@ -12,8 +12,8 @@ function rndName() {
|
||||
return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 10);
|
||||
}
|
||||
|
||||
async function createRandomFile(contents: string): Promise<vscode.Uri> {
|
||||
const tmpFile = join(os.tmpdir(), rndName());
|
||||
async function createRandomFile(contents: string, fileExtension: string): Promise<vscode.Uri> {
|
||||
const tmpFile = join(os.tmpdir(), rndName() + fileExtension);
|
||||
|
||||
try {
|
||||
fs.writeFileSync(tmpFile, contents);
|
||||
@ -41,8 +41,8 @@ export function assertEqual<T>(one: T, two: T, message: string = ""): void {
|
||||
assert.equal(one, two, message);
|
||||
}
|
||||
|
||||
export async function setupWorkspace(): Promise<any> {
|
||||
const file = await createRandomFile("");
|
||||
export async function setupWorkspace(fileExtension: string = ""): Promise<any> {
|
||||
const file = await createRandomFile("", fileExtension);
|
||||
const doc = await vscode.workspace.openTextDocument(file);
|
||||
|
||||
await vscode.window.showTextDocument(doc);
|
||||
|
@ -6,7 +6,9 @@ import { TextEditor } from './../src/textEditor';
|
||||
import { setupWorkspace, cleanUpWorkspace } from './testUtils';
|
||||
|
||||
suite("text editor", () => {
|
||||
suiteSetup(setupWorkspace);
|
||||
suiteSetup(async () => {
|
||||
await setupWorkspace();
|
||||
});
|
||||
|
||||
suiteTeardown(cleanUpWorkspace);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user