tests - add an integration test for editor contents from workspace file

This commit is contained in:
Benjamin Pasero 2019-11-04 13:22:58 +01:00
parent e8a6f3f01c
commit f5219f0fec
2 changed files with 1152 additions and 5 deletions

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection } from 'vscode';
import { workspace, window, Position, Range, commands, TextEditor, TextDocument, TextEditorCursorStyle, TextEditorLineNumbersStyle, SnippetString, Selection, Uri } from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors } from '../utils';
suite('editor tests', () => {
@ -197,11 +197,8 @@ suite('editor tests', () => {
});
test('throw when using invalid edit', async function () {
await withRandomFileEditor('foo', editor => {
return new Promise((resolve, reject) => {
editor.edit(edit => {
edit.insert(new Position(0, 0), 'bar');
setTimeout(() => {
@ -216,6 +213,21 @@ suite('editor tests', () => {
});
});
});
});
test('editor contents are correctly read (small file)', function () {
return testEditorContents('/far.js');
});
test('editor contents are correct read (large file)', async function () {
return testEditorContents('/lorem.txt');
});
async function testEditorContents(relativePath: string) {
const root = workspace.workspaceFolders![0]!.uri;
const file = Uri.parse(root.toString() + relativePath);
const document = await workspace.openTextDocument(file);
assert.equal(document.getText(), Buffer.from(await workspace.fs.readFile(file)).toString());
}
});

File diff suppressed because it is too large Load diff