mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 18:19:12 +01:00
add some tests
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable } from 'vscode';
|
||||
import { workspace, TextDocument, window, Position, Uri, EventEmitter, WorkspaceEdit, Disposable, EndOfLine } from 'vscode';
|
||||
import { createRandomFile, deleteFile, cleanUp, pathEquals } from './utils';
|
||||
import { join, basename } from 'path';
|
||||
import * as fs from 'fs';
|
||||
@@ -160,6 +160,41 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('eol, read', () => {
|
||||
const a = createRandomFile('foo\nbar\nbar').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.LF);
|
||||
});
|
||||
});
|
||||
const b = createRandomFile('foo\nbar\nbar\r\nbaz').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.LF);
|
||||
});
|
||||
});
|
||||
const c = createRandomFile('foo\r\nbar\r\nbar').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
});
|
||||
});
|
||||
return Promise.all([a, b, c]);
|
||||
});
|
||||
|
||||
test('eol, change via editor', () => {
|
||||
return createRandomFile('foo\nbar\nbar').then(file => {
|
||||
return workspace.openTextDocument(file).then(doc => {
|
||||
assert.equal(doc.eol, EndOfLine.LF);
|
||||
return window.showTextDocument(doc).then(editor => {
|
||||
return editor.edit(builder => builder.setEndOfLine(EndOfLine.CRLF));
|
||||
|
||||
}).then(value => {
|
||||
assert.ok(value);
|
||||
assert.ok(doc.isDirty);
|
||||
assert.equal(doc.eol, EndOfLine.CRLF);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
|
||||
return createRandomFile().then(file => {
|
||||
let disposables: Disposable[] = [];
|
||||
|
||||
Reference in New Issue
Block a user