]>
git.proxmox.com Git - mirror_xterm.js.git/blob - test/viewport-test.js
1 var assert
= require('chai').assert
;
2 var Terminal
= require('../src/xterm');
4 describe('Viewport', function () {
7 var charMeasureElement
;
11 var CHARACTER_HEIGHT
= 10;
13 beforeEach(function () {
26 addEventListener: function () {},
37 charMeasureElement
= {
38 getBoundingClientRect: function () {
39 return { width
: null, height
: CHARACTER_HEIGHT
};
42 viewport
= new Terminal
.Viewport(terminal
, viewportElement
, scrollAreaElement
, charMeasureElement
);
45 describe('Public API', function () {
46 it('should define Viewport.prototype.onWheel', function () {
47 assert
.isDefined(Terminal
.Viewport
.prototype.onWheel
);
51 describe('refresh', function () {
52 it('should set the line-height of the terminal', function () {
53 assert
.equal(viewportElement
.style
.lineHeight
, CHARACTER_HEIGHT
+ 'px');
54 assert
.equal(terminal
.rowContainer
.style
.lineHeight
, CHARACTER_HEIGHT
+ 'px');
55 charMeasureElement
.getBoundingClientRect = function () {
56 return { width
: null, height
: 1 };
59 assert
.equal(viewportElement
.style
.lineHeight
, '1px');
60 assert
.equal(terminal
.rowContainer
.style
.lineHeight
, '1px');
62 it('should set the height of the viewport when the line-height changed', function () {
63 terminal
.lines
.push('');
64 terminal
.lines
.push('');
67 assert
.equal(viewportElement
.style
.height
, 1 * CHARACTER_HEIGHT
+ 'px');
68 charMeasureElement
.getBoundingClientRect = function () {
69 return { width
: null, height
: 20 };
72 assert
.equal(viewportElement
.style
.height
, 20 + 'px');
76 describe('syncScrollArea', function () {
77 it('should sync the scroll area', function () {
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');