mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
tests for CellData
This commit is contained in:
+27
-1
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import * as chai from 'chai';
|
||||
import { BufferLine, CellData } from './BufferLine';
|
||||
import { BufferLine, CellData, Content } from './BufferLine';
|
||||
import { CharData, IBufferLine } from './Types';
|
||||
import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR } from './Buffer';
|
||||
|
||||
@@ -18,6 +18,32 @@ class TestBufferLine extends BufferLine {
|
||||
}
|
||||
}
|
||||
|
||||
describe('CellData', () => {
|
||||
it('CharData <--> CellData equality', () => {
|
||||
const cell = new CellData();
|
||||
// ASCII
|
||||
cell.setFromCharData([123, 'a', 1, 'a'.charCodeAt(0)]);
|
||||
chai.assert.deepEqual(cell.asCharData, [123, 'a', 1, 'a'.charCodeAt(0)]);
|
||||
chai.assert.equal(cell.combined, 0);
|
||||
// combining
|
||||
cell.setFromCharData([123, 'e\u0301', 1, '\u0301'.charCodeAt(0)]);
|
||||
chai.assert.deepEqual(cell.asCharData, [123, 'e\u0301', 1, '\u0301'.charCodeAt(0)]);
|
||||
chai.assert.equal(cell.combined, Content.IS_COMBINED);
|
||||
// surrogate
|
||||
cell.setFromCharData([123, '𝄞', 1, 0x1D11E]);
|
||||
chai.assert.deepEqual(cell.asCharData, [123, '𝄞', 1, 0x1D11E]);
|
||||
chai.assert.equal(cell.combined, 0);
|
||||
// surrogate + combining
|
||||
cell.setFromCharData([123, '𓂀\u0301', 1, '𓂀\u0301'.charCodeAt(2)]);
|
||||
chai.assert.deepEqual(cell.asCharData, [123, '𓂀\u0301', 1, '𓂀\u0301'.charCodeAt(2)]);
|
||||
chai.assert.equal(cell.combined, Content.IS_COMBINED);
|
||||
// wide char
|
||||
cell.setFromCharData([123, '1', 2, '1'.charCodeAt(0)]);
|
||||
chai.assert.deepEqual(cell.asCharData, [123, '1', 2, '1'.charCodeAt(0)]);
|
||||
chai.assert.equal(cell.combined, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('BufferLine', function(): void {
|
||||
it('ctor', function(): void {
|
||||
let line: IBufferLine = new TestBufferLine(0);
|
||||
|
||||
+4
-1
@@ -78,6 +78,8 @@ export const enum Content {
|
||||
|
||||
/**
|
||||
* CellData - represents a single Cell in the terminal buffer.
|
||||
*
|
||||
* TODO: attr getter
|
||||
*/
|
||||
export class CellData implements ICellData {
|
||||
|
||||
@@ -136,8 +138,9 @@ export class CellData implements ICellData {
|
||||
} else {
|
||||
combined = true;
|
||||
}
|
||||
} else {
|
||||
combined = true;
|
||||
}
|
||||
combined = true;
|
||||
} else {
|
||||
this.content = value[CHAR_DATA_CHAR_INDEX].charCodeAt(0) | (value[CHAR_DATA_WIDTH_INDEX] << Content.WIDTH_SHIFT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user