Skip to content

Commit

Permalink
fix test for microsoft#5649
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Apr 24, 2016
1 parent 9d91fce commit 8e0ebc3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 51 deletions.
30 changes: 14 additions & 16 deletions extensions/vscode-api-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@
},
"contributes": {
"configuration": {
"configuration": {
"type": "object",
"title": "Test Config",
"properties": {
"farboo.config0": {
"type": "boolean",
"default": true
},
"farboo.nested.config1": {
"type": "number",
"default": 42
},
"farboo.nested.config2": {
"type": "string",
"default": "Das Pferd frisst kein Reis."
}
"type": "object",
"title": "Test Config",
"properties": {
"farboo.config0": {
"type": "boolean",
"default": true
},
"farboo.nested.config1": {
"type": "number",
"default": 42
},
"farboo.nested.config2": {
"type": "string",
"default": "Das Pferd frisst kein Reis."
}
}
}
Expand Down
70 changes: 35 additions & 35 deletions extensions/vscode-api-tests/src/workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ suite('workspace-namespace', () => {

teardown(cleanUp);

// 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.');
// });
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.');
});

test('textDocuments', () => {
assert.ok(Array.isArray(workspace.textDocuments));
Expand All @@ -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);
Expand All @@ -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
}
Expand All @@ -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 => {
Expand All @@ -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() {
Expand All @@ -110,7 +110,7 @@ suite('workspace-namespace', () => {
]).then(() => {
registration.dispose();
});
})
});

test('events: onDidOpenTextDocument, onDidChangeTextDocument, onDidSaveTextDocument', () => {
return createRandomFile().then(file => {
Expand Down Expand Up @@ -156,7 +156,7 @@ suite('workspace-namespace', () => {
});
});

test('registerTextDocumentContentProvider, simple', function() {
test('registerTextDocumentContentProvider, simple', function () {

let registration = workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri) {
Expand All @@ -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', {
Expand All @@ -229,7 +229,7 @@ suite('workspace-namespace', () => {
});
let registration2 = workspace.registerTextDocumentContentProvider('foo', {
provideTextDocumentContent(uri): string {
throw new Error('fail')
throw new Error('fail');
}
});

Expand All @@ -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) {
Expand All @@ -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', {
Expand All @@ -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>();
Expand Down

0 comments on commit 8e0ebc3

Please sign in to comment.