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', done => {
45 // Allow CharMeasure to be initialized
47 assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
48 assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
49 charMeasure.height = 1;
51 assert.equal(viewportElement.style.lineHeight, '1px');
52 assert.equal(terminal.rowContainer.style.lineHeight, '1px');
56 it('should set the height of the viewport when the line-height changed', () => {
57 terminal.lines.push('');
58 terminal.lines.push('');
61 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
62 charMeasure.height = 20;
64 assert.equal(viewportElement.style.height, 20 + 'px');
68 describe('syncScrollArea', () => {
69 it('should sync the scroll area', done => {
70 // Allow CharMeasure to be initialized
72 terminal.lines.push('');
74 assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
75 viewport.syncScrollArea();
76 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
77 assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
78 terminal.lines.push('');
79 viewport.syncScrollArea();
80 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
81 assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');