Implement Terminal.creationOptions API

Fixes #63052
This commit is contained in:
Daniel Imms
2019-11-05 10:30:43 -08:00
parent 5d3c599e9b
commit 1d60909d1f
6 changed files with 87 additions and 9 deletions

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { window, Pseudoterminal, EventEmitter, TerminalDimensions, workspace, ConfigurationTarget, Disposable } from 'vscode';
import { doesNotThrow, equal, ok, deepEqual } from 'assert';
import { doesNotThrow, equal, ok, deepEqual, throws } from 'assert';
suite('window namespace tests', () => {
suiteSetup(async () => {
@@ -84,6 +84,30 @@ suite('window namespace tests', () => {
}
});
test('creationOptions should be set and readonly for TerminalOptions terminals', (done) => {
disposables.push(window.onDidOpenTerminal(term => {
try {
equal(terminal, term);
} catch (e) {
done(e);
}
terminal.dispose();
disposables.push(window.onDidCloseTerminal(() => done()));
}));
const options = {
name: 'foo',
hideFromUser: true
};
const terminal = window.createTerminal(options);
try {
equal(terminal.name, 'foo');
deepEqual(terminal.creationOptions, options);
throws(() => (<any>terminal.creationOptions).name = 'bad', 'creationOptions should be readonly at runtime');
} catch (e) {
done(e);
}
});
test('onDidOpenTerminal should fire when a terminal is created', (done) => {
disposables.push(window.onDidOpenTerminal(term => {
try {
@@ -369,6 +393,33 @@ suite('window namespace tests', () => {
};
const terminal = window.createTerminal({ name: 'foo', pty });
});
test('creationOptions should be set and readonly for ExtensionTerminalOptions terminals', (done) => {
disposables.push(window.onDidOpenTerminal(term => {
try {
equal(terminal, term);
} catch (e) {
done(e);
}
terminal.dispose();
disposables.push(window.onDidCloseTerminal(() => done()));
}));
const writeEmitter = new EventEmitter<string>();
const pty: Pseudoterminal = {
onDidWrite: writeEmitter.event,
open: () => { },
close: () => { }
};
const options = { name: 'foo', pty };
const terminal = window.createTerminal(options);
try {
equal(terminal.name, 'foo');
deepEqual(terminal.creationOptions, options);
throws(() => (<any>terminal.creationOptions).name = 'bad', 'creationOptions should be readonly at runtime');
} catch (e) {
done(e);
}
});
});
});
});