Add pinning test for webview html update

This commit is contained in:
Matt Bierner 2018-10-05 16:08:33 -07:00
parent 676ea4b5c5
commit 23fedc5a3e

View file

@ -47,6 +47,31 @@ suite('Webview tests', () => {
assert.strictEqual((await firstResponse).value, 2);
});
test('webviews should update html', async () => {
const webview = _register(vscode.window.createWebviewPanel(webviewId, 'title', { viewColumn: vscode.ViewColumn.One }, { enableScripts: true }));
{
const response = getMesssage(webview);
webview.webview.html = createHtmlDocumentWithBody(/*html*/`
<script>
const vscode = acquireVsCodeApi();
vscode.postMessage({ value: 'first' });
</script>`);
assert.strictEqual((await response).value, 'first');
}
{
const firstResponse = getMesssage(webview);
webview.webview.html = createHtmlDocumentWithBody(/*html*/`
<script>
const vscode = acquireVsCodeApi();
vscode.postMessage({ value: 'second' });
</script>`);
assert.strictEqual((await firstResponse).value, 'second');
}
});
test('webviews should preserve vscode API state when they are hidden', async () => {
const webview = _register(vscode.window.createWebviewPanel(webviewId, 'title', { viewColumn: vscode.ViewColumn.One }, { enableScripts: true }));
const ready = getMesssage(webview);