1 import { assert } from 'chai';
2 import { Viewport } from './Viewport';
4 describe('Viewport', () => {
7 let selectionContainer;
10 let scrollAreaElement;
12 const CHARACTER_HEIGHT = 10;
32 addEventListener: () => {},
44 height: CHARACTER_HEIGHT
46 viewport = new Viewport(terminal, viewportElement, scrollAreaElement, charMeasure);
49 describe('refresh', () => {
50 it('should set the line-height of the terminal', done => {
51 // Allow CharMeasure to be initialized
53 assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
54 assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
55 charMeasure.height = 1;
57 assert.equal(viewportElement.style.lineHeight, '1px');
58 assert.equal(terminal.rowContainer.style.lineHeight, '1px');
62 it('should set the height of the viewport when the line-height changed', () => {
63 terminal.lines.push('');
64 terminal.lines.push('');
67 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
68 charMeasure.height = 20;
70 assert.equal(viewportElement.style.height, 20 + 'px');
74 describe('syncScrollArea', () => {
75 it('should sync the scroll area', done => {
76 // Allow CharMeasure to be initialized
78 terminal.lines.push('');
80 assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
81 viewport.syncScrollArea();
82 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
83 assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
84 terminal.lines.push('');
85 viewport.syncScrollArea();
86 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
87 assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');