mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Move options test to Terminal.api.ts
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Terminal } from 'browser/public/Terminal';
|
||||
import { assert } from 'chai';
|
||||
import { ITerminalOptions } from 'common/Types';
|
||||
|
||||
const INIT_COLS = 80;
|
||||
const INIT_ROWS = 24;
|
||||
|
||||
describe('Public Terminal', () => {
|
||||
let term: Terminal;
|
||||
const termOptions = {
|
||||
cols: INIT_COLS,
|
||||
rows: INIT_ROWS
|
||||
};
|
||||
|
||||
describe('options', () => {
|
||||
beforeEach(async () => {
|
||||
term = new Terminal(termOptions);
|
||||
});
|
||||
it('get options', () => {
|
||||
const options: ITerminalOptions = term.options;
|
||||
assert.equal(options.cols, 80);
|
||||
assert.equal(options.rows, 24);
|
||||
});
|
||||
it('set options', async () => {
|
||||
const options: ITerminalOptions = term.options;
|
||||
assert.throws(() => options.cols = 40);
|
||||
assert.throws(() => options.rows = 20);
|
||||
term.options.scrollback = 1;
|
||||
assert.equal(term.options.scrollback, 1);
|
||||
term.options= {
|
||||
fontSize: 12,
|
||||
fontFamily: 'Arial'
|
||||
};
|
||||
assert.equal(term.options.fontSize, 12);
|
||||
assert.equal(term.options.fontFamily, 'Arial');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@
|
||||
import { assert } from 'chai';
|
||||
import { pollFor, timeout, writeSync, openTerminal, launchBrowser } from './TestUtils';
|
||||
import { Browser, Page } from 'playwright';
|
||||
import { fail } from 'assert';
|
||||
|
||||
const APP = 'http://127.0.0.1:3001/test';
|
||||
|
||||
@@ -160,6 +161,36 @@ describe('API Integration Tests', function(): void {
|
||||
assert.equal(await page.evaluate(`window.term.getOption('rendererType')`), 'dom');
|
||||
});
|
||||
|
||||
describe('options', () => {
|
||||
it('getter', async () => {
|
||||
await openTerminal(page);
|
||||
assert.equal(await page.evaluate(`window.term.options.rendererType`), 'canvas');
|
||||
assert.equal(await page.evaluate(`window.term.options.cols`), 80);
|
||||
assert.equal(await page.evaluate(`window.term.options.rows`), 24);
|
||||
});
|
||||
it('setter', async () => {
|
||||
await openTerminal(page);
|
||||
try {
|
||||
await page.evaluate('window.term.options.cols = 40');
|
||||
fail();
|
||||
} catch {}
|
||||
try {
|
||||
await page.evaluate('window.term.options.rows = 20');
|
||||
fail();
|
||||
} catch {}
|
||||
await page.evaluate('window.term.options.scrollback = 1');
|
||||
assert.equal(await page.evaluate(`window.term.options.scrollback`), 1);
|
||||
await page.evaluate(`
|
||||
window.term.options = {
|
||||
fontSize: 30,
|
||||
fontFamily: 'Arial'
|
||||
};
|
||||
`);
|
||||
assert.equal(await page.evaluate(`window.term.options.fontSize`), 30);
|
||||
assert.equal(await page.evaluate(`window.term.options.fontFamily`), 'Arial');
|
||||
});
|
||||
});
|
||||
|
||||
describe('renderer', () => {
|
||||
it('foreground', async () => {
|
||||
await openTerminal(page, { rendererType: 'dom' });
|
||||
|
||||
Reference in New Issue
Block a user