Start on headless unit tests

This commit is contained in:
Daniel Imms
2021-08-12 05:35:20 -07:00
parent ec80fc9421
commit e96b472ede
3 changed files with 553 additions and 39 deletions
-27
View File
@@ -1,27 +0,0 @@
/**
* Copyright (c) 2016 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { deepStrictEqual, throws } from 'assert';
import { Terminal } from 'headless/public/Terminal';
const INIT_COLS = 80;
const INIT_ROWS = 24;
describe('Headless Terminal', () => {
let term: Terminal;
const termOptions = {
cols: INIT_COLS,
rows: INIT_ROWS
};
beforeEach(() => {
term = new Terminal(termOptions);
});
it('should throw when trying to change cols or rows', () => {
throws(() => term.setOption('cols', 1000));
throws(() => term.setOption('rows', 1000));
});
});
File diff suppressed because it is too large Load Diff
+6 -12
View File
@@ -69,12 +69,9 @@ describe('API Integration Tests', function(): void {
it('write - bytes (UTF8)', async () => {
await openTerminal(page);
await page.evaluate(`
// foo
window.term.write(new Uint8Array([102, 111, 111]));
// bar
window.term.write(new Uint8Array([98, 97, 114]));
// 文
window.term.write(new Uint8Array([230, 150, 135]));
window.term.write(new Uint8Array([102, 111, 111])); // foo
window.term.write(new Uint8Array([98, 97, 114])); // bar
window.term.write(new Uint8Array([230, 150, 135])); // 文
`);
await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文');
});
@@ -82,12 +79,9 @@ describe('API Integration Tests', function(): void {
it('write - bytes (UTF8) with callback', async () => {
await openTerminal(page);
await page.evaluate(`
// foo
window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; });
// bar
window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; });
// 文
window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; });
window.term.write(new Uint8Array([102, 111, 111]), () => { window.__x = 'A'; }); // foo
window.term.write(new Uint8Array([98, 97, 114]), () => { window.__x += 'B'; }); // bar
window.term.write(new Uint8Array([230, 150, 135]), () => { window.__x += 'C'; }); // 文
`);
await pollFor(page, `window.term.buffer.active.getLine(0).translateToString(true)`, 'foobar文');
await pollFor(page, `window.__x`, 'ABC');