Vim/test/textEditor.test.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

import * as assert from 'assert';
import * as vscode from 'vscode';
2017-12-11 16:05:43 +03:00
2016-06-06 07:53:06 +03:00
import { TextEditor } from './../src/textEditor';
2017-12-11 16:05:43 +03:00
import { cleanUpWorkspace, setupWorkspace } from './testUtils';
2017-06-28 03:02:35 +03:00
suite('text editor', () => {
2017-04-13 21:18:15 +03:00
suiteSetup(async () => {
await setupWorkspace();
});
suiteTeardown(cleanUpWorkspace);
2015-12-02 04:53:31 +03:00
test("insert 'Hello World'", async () => {
const editor = vscode.window.activeTextEditor!;
const expectedText = 'Hello World';
2015-12-02 04:53:31 +03:00
await TextEditor.insert(editor, expectedText);
assert.strictEqual(editor.document.lineCount, 1);
assert.strictEqual(editor.document.lineAt(0).text, expectedText);
});
2015-12-02 04:53:31 +03:00
test("replace 'World' with 'Foo Bar'", async () => {
const editor = vscode.window.activeTextEditor!;
const newText = 'Foo Bar';
const start = new vscode.Position(0, 6);
const end = new vscode.Position(0, 11);
const range: vscode.Range = new vscode.Range(start, end);
await TextEditor.replace(editor, range, newText);
assert.strictEqual(editor.document.lineCount, 1);
assert.strictEqual(editor.document.lineAt(0).text, 'Hello Foo Bar');
});
});