1 import { assert } from 'chai';
2 import { Viewport } from './Viewport';
4 describe('Viewport', () => {
11 const CHARACTER_HEIGHT = 10;
26 addEventListener: () => {},
38 height: CHARACTER_HEIGHT
40 viewport = new Viewport(terminal, viewportElement, scrollAreaElement, charMeasure);
43 describe('refresh', () => {
44 it('should set the line-height of the terminal', () => {
45 assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
46 assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
47 charMeasure.height = 1;
49 assert.equal(viewportElement.style.lineHeight, '1px');
50 assert.equal(terminal.rowContainer.style.lineHeight, '1px');
52 it('should set the height of the viewport when the line-height changed', () => {
53 terminal.lines.push('');
54 terminal.lines.push('');
57 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
58 charMeasure.height = 20;
60 assert.equal(viewportElement.style.height, 20 + 'px');
64 describe('syncScrollArea', () => {
65 it('should sync the scroll area', () => {
66 terminal.lines.push('');
68 assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
69 viewport.syncScrollArea();
70 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
71 assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
72 terminal.lines.push('');
73 viewport.syncScrollArea();
74 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
75 assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');