Fill out typings tests
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Terminal } from 'xterm';
|
import { Terminal } from 'xterm';
|
||||||
|
|
||||||
namespace constructor_tests {
|
namespace constructor {
|
||||||
{
|
{
|
||||||
new Terminal();
|
new Terminal();
|
||||||
new Terminal({});
|
new Terminal({});
|
||||||
@@ -21,3 +21,188 @@ namespace constructor_tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace properties {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
const element: HTMLElement = t.element;
|
||||||
|
const textarea: HTMLTextAreaElement = t.textarea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace static_methods {
|
||||||
|
{
|
||||||
|
Terminal.loadAddon('attach');
|
||||||
|
Terminal.loadAddon('fit');
|
||||||
|
Terminal.loadAddon('fullscreen');
|
||||||
|
Terminal.loadAddon('search');
|
||||||
|
Terminal.loadAddon('terminado');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace methods_core {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
t.blur();
|
||||||
|
t.focus();
|
||||||
|
t.destroy();
|
||||||
|
t.clear();
|
||||||
|
t.refresh(0, 1);
|
||||||
|
t.reset();
|
||||||
|
t.resize(1, 1);
|
||||||
|
t.write('foo');
|
||||||
|
t.writeln('foo');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
// no arg
|
||||||
|
t.on('blur', () => {});
|
||||||
|
t.on('focus', () => {});
|
||||||
|
t.on('lineFeed', () => {});
|
||||||
|
t.on('open', () => {});
|
||||||
|
// args
|
||||||
|
t.on('data', () => {});
|
||||||
|
t.on('data', (data: string) => console.log(data));
|
||||||
|
t.on('key', () => {});
|
||||||
|
t.on('key', (key: string) => console.log(key, event));
|
||||||
|
t.on('key', (key: string, event: KeyboardEvent) => console.log(key, event));
|
||||||
|
t.on('keydown', () => {});
|
||||||
|
t.on('keydown', (event: KeyboardEvent) => console.log(event));
|
||||||
|
t.on('keypress', () => {});
|
||||||
|
t.on('keypress', (event: KeyboardEvent) => console.log(event));
|
||||||
|
t.on('refresh', () => {});
|
||||||
|
t.on('refresh', (data: {element: HTMLElement, start: number, end: number}) => console.log(data));
|
||||||
|
t.on('resize', () => {});
|
||||||
|
t.on('resize', (data: {terminal: Terminal, cols: number, rows: number}) => console.log(data));
|
||||||
|
t.on('scroll', () => {});
|
||||||
|
t.on('scroll', (ydisp: number) => console.log(ydisp));
|
||||||
|
t.on('title', () => {});
|
||||||
|
t.on('title', (title: string) => console.log(title));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
// no arg
|
||||||
|
t.off('blur', () => {});
|
||||||
|
t.off('focus', () => {});
|
||||||
|
t.off('lineFeed', () => {});
|
||||||
|
t.off('open', () => {});
|
||||||
|
// args
|
||||||
|
t.off('data', () => {});
|
||||||
|
t.off('data', (data: string) => console.log(data));
|
||||||
|
t.off('key', () => {});
|
||||||
|
t.off('key', (key: string) => console.log(key, event));
|
||||||
|
t.off('key', (key: string, event: KeyboardEvent) => console.log(key, event));
|
||||||
|
t.off('keydown', () => {});
|
||||||
|
t.off('keydown', (event: KeyboardEvent) => console.log(event));
|
||||||
|
t.off('keypress', () => {});
|
||||||
|
t.off('keypress', (event: KeyboardEvent) => console.log(event));
|
||||||
|
t.off('refresh', () => {});
|
||||||
|
t.off('refresh', (data: {element: HTMLElement, start: number, end: number}) => console.log(data));
|
||||||
|
t.off('resize', () => {});
|
||||||
|
t.off('resize', (data: {terminal: Terminal, cols: number, rows: number}) => console.log(data));
|
||||||
|
t.off('scroll', () => {});
|
||||||
|
t.off('scroll', (ydisp: number) => console.log(ydisp));
|
||||||
|
t.off('title', () => {});
|
||||||
|
t.off('title', (title: string) => console.log(title));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
const e: HTMLElement = null;
|
||||||
|
t.open(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
t.attachCustomKeyEventHandler((e: KeyboardEvent) => true);
|
||||||
|
t.attachCustomKeyEventHandler((e: KeyboardEvent) => false);
|
||||||
|
}
|
||||||
|
namespace options {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
const r01: string = t.getOption('cursorStyle');
|
||||||
|
const r02: string = t.getOption('termName');
|
||||||
|
const r03: boolean = t.getOption('cancelEvents');
|
||||||
|
const r04: boolean = t.getOption('convertEol');
|
||||||
|
const r05: boolean = t.getOption('cursorBlink');
|
||||||
|
const r06: boolean = t.getOption('debug');
|
||||||
|
const r07: boolean = t.getOption('disableStdin');
|
||||||
|
const r08: boolean = t.getOption('popOnBell');
|
||||||
|
const r09: boolean = t.getOption('screenKeys');
|
||||||
|
const r10: boolean = t.getOption('useFlowControl');
|
||||||
|
const r11: boolean = t.getOption('visualBell');
|
||||||
|
const r12: string[] = t.getOption('colors');
|
||||||
|
const r13: number = t.getOption('cols');
|
||||||
|
const r14: number = t.getOption('rows');
|
||||||
|
const r15: number = t.getOption('tabStopWidth');
|
||||||
|
const r16: number = t.getOption('scrollback');
|
||||||
|
const r17: [number, number] = t.getOption('geometry');
|
||||||
|
const r18: (data: string) => void = t.getOption('handler');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
t.setOption('cursorStyle', 'foo');
|
||||||
|
t.setOption('termName', 'foo');
|
||||||
|
t.setOption('cancelEvents', true);
|
||||||
|
t.setOption('convertEol', true);
|
||||||
|
t.setOption('cursorBlink', true);
|
||||||
|
t.setOption('debug', true);
|
||||||
|
t.setOption('disableStdin', true);
|
||||||
|
t.setOption('popOnBell', true);
|
||||||
|
t.setOption('screenKeys', true);
|
||||||
|
t.setOption('useFlowControl', true);
|
||||||
|
t.setOption('visualBell', true);
|
||||||
|
t.setOption('colors', ['a', 'b']);
|
||||||
|
t.setOption('cols', 1);
|
||||||
|
t.setOption('rows', 1);
|
||||||
|
t.setOption('tabStopWidth', 1);
|
||||||
|
t.setOption('scrollback', 1);
|
||||||
|
t.setOption('geometry', [1, 1]);
|
||||||
|
t.setOption('handler', (data: string) => console.log(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
namespace scrolling {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
t.scrollDisp(-1);
|
||||||
|
t.scrollDisp(1);
|
||||||
|
t.scrollDisp(-1);
|
||||||
|
t.scrollDisp(1);
|
||||||
|
t.scrollToTop();
|
||||||
|
t.scrollToBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
namespace selection {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
const r1: boolean = t.hasSelection();
|
||||||
|
const r2: string = t.getSelection();
|
||||||
|
t.clearSelection();
|
||||||
|
t.selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace methods_experimental {
|
||||||
|
{
|
||||||
|
const t: Terminal = new Terminal();
|
||||||
|
t.registerLinkMatcher(/foo/, () => {});
|
||||||
|
t.registerLinkMatcher(new RegExp('foo'), () => {});
|
||||||
|
t.registerLinkMatcher(/foo/, () => {}, {});
|
||||||
|
t.registerLinkMatcher(/foo/, (event: MouseEvent, uri: string) => {
|
||||||
|
console.log(event, uri);
|
||||||
|
return void 0;
|
||||||
|
}, {});
|
||||||
|
t.registerLinkMatcher(/foo/, () => true, {});
|
||||||
|
t.registerLinkMatcher(/foo/, () => false, {});
|
||||||
|
t.registerLinkMatcher(/foo/, () => true, {
|
||||||
|
matchIndex: 1
|
||||||
|
});
|
||||||
|
t.registerLinkMatcher(/foo/, () => true, {
|
||||||
|
matchIndex: 1,
|
||||||
|
priority: 1,
|
||||||
|
validationCallback: (uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => {
|
||||||
|
console.log(uri, element, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t.deregisterLinkMatcher(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ if (os.platform() !== 'win32') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('typings', () => {
|
describe('typings', () => {
|
||||||
it('should throw no compile errors', () => {
|
it('should throw no compile errors', function () {
|
||||||
|
this.timeout(20000);
|
||||||
let result = cp.spawnSync(path.join(__dirname, '..', 'node_modules', '.bin', 'tsc'), {
|
let result = cp.spawnSync(path.join(__dirname, '..', 'node_modules', '.bin', 'tsc'), {
|
||||||
cwd: path.join(__dirname, '..', 'fixtures', 'typings-test')
|
cwd: path.join(__dirname, '..', 'fixtures', 'typings-test')
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -414,7 +414,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
|||||||
*/
|
*/
|
||||||
public getOption(key: StringOption): string;
|
public getOption(key: StringOption): string;
|
||||||
public getOption(key: BooleanOption): boolean;
|
public getOption(key: BooleanOption): boolean;
|
||||||
public getOption(key: StringArrayOption): number[];
|
public getOption(key: StringArrayOption): string[];
|
||||||
public getOption(key: NumberOption): number;
|
public getOption(key: NumberOption): number;
|
||||||
public getOption(key: GeometryOption): [number, number];
|
public getOption(key: GeometryOption): [number, number];
|
||||||
public getOption(key: HandlerOption): (data: string) => void;
|
public getOption(key: HandlerOption): (data: string) => void;
|
||||||
|
|||||||
Vendored
+3
-3
@@ -193,7 +193,7 @@ declare module 'xterm' {
|
|||||||
* @param options Options for the link matcher.
|
* @param options Options for the link matcher.
|
||||||
* @return The ID of the new matcher, this can be used to deregister.
|
* @return The ID of the new matcher, this can be used to deregister.
|
||||||
*/
|
*/
|
||||||
registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => boolean | void , options?: any): number;
|
registerLinkMatcher(regex: RegExp, handler: (event: MouseEvent, uri: string) => boolean | void , options?: ILinkMatcherOptions): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (EXPERIMENTAL) Deregisters a link matcher if it has been registered.
|
* (EXPERIMENTAL) Deregisters a link matcher if it has been registered.
|
||||||
@@ -290,7 +290,7 @@ declare module 'xterm' {
|
|||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
*/
|
*/
|
||||||
getOption(key: 'colors'): number[];
|
getOption(key: 'colors'): string[];
|
||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
@@ -324,7 +324,7 @@ declare module 'xterm' {
|
|||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'colors', value: number[]): void;
|
setOption(key: 'colors', value: string[]): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
|||||||
Reference in New Issue
Block a user