mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
fix test for #5649
This commit is contained in:
@@ -15,16 +15,16 @@ suite('workspace-namespace', () => {
|
||||
|
||||
teardown(cleanUp);
|
||||
|
||||
// test('default configuration', () => {
|
||||
// const config = workspace.getConfiguration('farboo');
|
||||
test('default configuration', () => {
|
||||
const config = workspace.getConfiguration('farboo');
|
||||
|
||||
// assert.ok(config.has('config0'));
|
||||
// assert.equal(config.get('config0'), true);
|
||||
// assert.ok(config.has('nested.config1'));
|
||||
// assert.equal(config.get('nested.config1'), 42);
|
||||
// assert.ok(config.has('nested.config2'));
|
||||
// assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
|
||||
// });
|
||||
assert.ok(config.has('config0'));
|
||||
assert.equal(config.get('config0'), true);
|
||||
assert.ok(config.has('nested.config1'));
|
||||
assert.equal(config.get('nested.config1'), 42);
|
||||
assert.ok(config.has('nested.config2'));
|
||||
assert.equal(config.get('nested.config2'), 'Das Pferd frisst kein Reis.');
|
||||
});
|
||||
|
||||
test('textDocuments', () => {
|
||||
assert.ok(Array.isArray(workspace.textDocuments));
|
||||
@@ -37,7 +37,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
|
||||
test('openTextDocument', () => {
|
||||
let len = workspace.textDocuments.length
|
||||
let len = workspace.textDocuments.length;
|
||||
return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
|
||||
assert.ok(doc);
|
||||
assert.equal(workspace.textDocuments.length, len + 1);
|
||||
@@ -52,7 +52,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, untitled is dirty', function(done) {
|
||||
test('openTextDocument, untitled is dirty', function (done) {
|
||||
if (process.platform === 'win32') {
|
||||
return done(); // TODO@Joh this test fails on windows
|
||||
}
|
||||
@@ -64,7 +64,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, untitled closes on save', function() {
|
||||
test('openTextDocument, untitled closes on save', function () {
|
||||
const path = join(workspace.rootPath, './newfile.txt');
|
||||
|
||||
return workspace.openTextDocument(Uri.parse('untitled://' + path)).then(doc => {
|
||||
@@ -86,7 +86,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, uri scheme/auth/path', function() {
|
||||
test('openTextDocument, uri scheme/auth/path', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('sc', {
|
||||
provideTextDocumentContent() {
|
||||
@@ -110,7 +110,7 @@ suite('workspace-namespace', () => {
|
||||
]).then(() => {
|
||||
registration.dispose();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
|
||||
return createRandomFile().then(file => {
|
||||
@@ -156,7 +156,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, simple', function() {
|
||||
test('registerTextDocumentContentProvider, simple', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
@@ -173,53 +173,53 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, constrains', function() {
|
||||
test('registerTextDocumentContentProvider, constrains', function () {
|
||||
|
||||
// built-in
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
workspace.registerTextDocumentContentProvider('untitled', { provideTextDocumentContent() { return null; } });
|
||||
});
|
||||
// built-in
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
workspace.registerTextDocumentContentProvider('file', { provideTextDocumentContent() { return null; } });
|
||||
});
|
||||
|
||||
// missing scheme
|
||||
return workspace.openTextDocument(Uri.parse('notThere://foo/far/boo/bar')).then(() => {
|
||||
assert.ok(false, 'expected failure')
|
||||
assert.ok(false, 'expected failure');
|
||||
}, err => {
|
||||
// expected
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, multiple', function() {
|
||||
test('registerTextDocumentContentProvider, multiple', function () {
|
||||
|
||||
// duplicate registration
|
||||
let registration1 = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
if (uri.authority === 'foo') {
|
||||
return '1'
|
||||
return '1';
|
||||
}
|
||||
}
|
||||
});
|
||||
let registration2 = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
if (uri.authority === 'bar') {
|
||||
return '2'
|
||||
return '2';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
workspace.openTextDocument(Uri.parse('foo://foo/bla')).then(doc => { assert.equal(doc.getText(), '1') }),
|
||||
workspace.openTextDocument(Uri.parse('foo://bar/bla')).then(doc => { assert.equal(doc.getText(), '2') })
|
||||
workspace.openTextDocument(Uri.parse('foo://foo/bla')).then(doc => { assert.equal(doc.getText(), '1'); }),
|
||||
workspace.openTextDocument(Uri.parse('foo://bar/bla')).then(doc => { assert.equal(doc.getText(), '2'); })
|
||||
]).then(() => {
|
||||
registration1.dispose();
|
||||
registration2.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, evil provider', function() {
|
||||
test('registerTextDocumentContentProvider, evil provider', function () {
|
||||
|
||||
// duplicate registration
|
||||
let registration1 = workspace.registerTextDocumentContentProvider('foo', {
|
||||
@@ -229,7 +229,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
let registration2 = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri): string {
|
||||
throw new Error('fail')
|
||||
throw new Error('fail');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -240,22 +240,22 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, invalid text', function() {
|
||||
test('registerTextDocumentContentProvider, invalid text', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
return <any> 123
|
||||
return <any>123;
|
||||
}
|
||||
});
|
||||
return workspace.openTextDocument(Uri.parse('foo://auth/path')).then(() => {
|
||||
assert.ok(false, 'expected failure')
|
||||
assert.ok(false, 'expected failure');
|
||||
}, err => {
|
||||
// expected
|
||||
registration.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, show virtual document', function() {
|
||||
test('registerTextDocumentContentProvider, show virtual document', function () {
|
||||
|
||||
let registration = workspace.registerTextDocumentContentProvider('foo', {
|
||||
provideTextDocumentContent(uri) {
|
||||
@@ -269,11 +269,11 @@ suite('workspace-namespace', () => {
|
||||
assert.ok(editor.document === doc);
|
||||
assert.equal(editor.document.getText(), 'I am virtual');
|
||||
registration.dispose();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, open/open document', function() {
|
||||
test('registerTextDocumentContentProvider, open/open document', function () {
|
||||
|
||||
let callCount = 0;
|
||||
let registration = workspace.registerTextDocumentContentProvider('foo', {
|
||||
@@ -294,7 +294,7 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('registerTextDocumentContentProvider, change event', function() {
|
||||
test('registerTextDocumentContentProvider, change event', function () {
|
||||
|
||||
let callCount = 0;
|
||||
let emitter = new EventEmitter<Uri>();
|
||||
|
||||
Reference in New Issue
Block a user