2015-12-01 22:57:38 +03:00
|
|
|
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';
|
2015-12-02 05:12:43 +03:00
|
|
|
|
2017-06-28 03:02:35 +03:00
|
|
|
suite('text editor', () => {
|
2017-04-13 21:18:15 +03:00
|
|
|
suiteSetup(async () => {
|
|
|
|
await setupWorkspace();
|
|
|
|
});
|
2015-12-01 22:57:38 +03:00
|
|
|
|
2016-07-16 20:02:31 +03:00
|
|
|
suiteTeardown(cleanUpWorkspace);
|
2015-12-02 04:53:31 +03:00
|
|
|
|
2016-07-16 20:02:31 +03:00
|
|
|
test("insert 'Hello World'", async () => {
|
2020-11-25 06:07:46 +03:00
|
|
|
const editor = vscode.window.activeTextEditor!;
|
2019-10-21 06:25:01 +03:00
|
|
|
const expectedText = 'Hello World';
|
2015-12-02 04:53:31 +03:00
|
|
|
|
2020-11-25 06:07:46 +03:00
|
|
|
await TextEditor.insert(editor, expectedText);
|
2016-02-07 09:37:46 +03:00
|
|
|
|
2020-11-25 06:07:46 +03:00
|
|
|
assert.strictEqual(editor.document.lineCount, 1);
|
|
|
|
assert.strictEqual(editor.document.lineAt(0).text, expectedText);
|
2016-07-16 20:02:31 +03:00
|
|
|
});
|
2015-12-02 04:53:31 +03:00
|
|
|
|
2016-07-16 20:02:31 +03:00
|
|
|
test("replace 'World' with 'Foo Bar'", async () => {
|
2020-11-25 06:07:46 +03:00
|
|
|
const editor = vscode.window.activeTextEditor!;
|
2019-10-21 06:25:01 +03:00
|
|
|
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);
|
2015-12-01 22:57:38 +03:00
|
|
|
|
2020-11-25 06:07:46 +03:00
|
|
|
await TextEditor.replace(editor, range, newText);
|
|
|
|
assert.strictEqual(editor.document.lineCount, 1);
|
|
|
|
assert.strictEqual(editor.document.lineAt(0).text, 'Hello Foo Bar');
|
2016-07-16 20:02:31 +03:00
|
|
|
});
|
2015-12-01 22:57:38 +03:00
|
|
|
});
|