1 import { assert } from 'chai';
2 import { Viewport } from './Viewport';
3 import {BufferSet} from './BufferSet';
5 describe('Viewport', () => {
10 let scrollAreaElement;
12 const CHARACTER_HEIGHT = 10;
31 terminal.buffers = new BufferSet(terminal);
32 terminal.buffer = terminal.buffers.active;
34 addEventListener: () => {},
46 height: CHARACTER_HEIGHT
48 viewport = new Viewport(terminal, viewportElement, scrollAreaElement, charMeasure);
51 describe('refresh', () => {
52 it('should set the line-height of the terminal', done => {
53 // Allow CharMeasure to be initialized
55 assert.equal(viewportElement.style.lineHeight, CHARACTER_HEIGHT + 'px');
56 assert.equal(terminal.rowContainer.style.lineHeight, CHARACTER_HEIGHT + 'px');
57 charMeasure.height = 1;
59 assert.equal(viewportElement.style.lineHeight, '1px');
60 assert.equal(terminal.rowContainer.style.lineHeight, '1px');
64 it('should set the height of the viewport when the line-height changed', () => {
65 terminal.buffer.lines.push('');
66 terminal.buffer.lines.push('');
69 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
70 charMeasure.height = 2 * CHARACTER_HEIGHT;
72 assert.equal(viewportElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
76 describe('syncScrollArea', () => {
77 it('should sync the scroll area', done => {
78 // Allow CharMeasure to be initialized
80 terminal.buffer.lines.push('');
82 assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
83 viewport.syncScrollArea();
84 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
85 assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
86 terminal.buffer.lines.push('');
87 viewport.syncScrollArea();
88 assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
89 assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');