add html preview sample

This commit is contained in:
Johannes Rieken 2016-01-18 18:27:18 +01:00
parent 79e032c169
commit a6aa8ddf80
2 changed files with 21 additions and 4 deletions

View file

@ -6,8 +6,7 @@
'use strict';
import * as assert from 'assert';
import {commands} from 'vscode';
import {join} from 'path';
import {commands, workspace, Uri} from 'vscode';
suite("commands namespace tests", () => {
@ -39,4 +38,21 @@ suite("commands namespace tests", () => {
done();
}, done);
});
});
test('api-command: workbench.html.preview', function() {
let registration = workspace.registerTextDocumentContentProvider('speciale', {
provideTextDocumentContent(uri) {
return `content of URI <b>${uri.toString()}</b>`;
}
});
let virtualDocumentUri = Uri.parse('speciale://authority/path')
return commands.executeCommand('workbench.html.preview', virtualDocumentUri).then(success => {
assert.ok(success);
registration.dispose();
});
})
});

View file

@ -26,9 +26,10 @@ suite('workspace-namespace', () => {
});
test('openTextDocument', () => {
let len = workspace.textDocuments.length
return workspace.openTextDocument(join(workspace.rootPath, './far.js')).then(doc => {
assert.ok(doc);
assert.equal(workspace.textDocuments.length, 1);
assert.equal(workspace.textDocuments.length, len + 1);
});
});