]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Fix tests
authorDaniel Imms <daimms@microsoft.com>
Wed, 4 Jan 2017 18:30:04 +0000 (10:30 -0800)
committerDaniel Imms <daimms@microsoft.com>
Wed, 4 Jan 2017 18:30:04 +0000 (10:30 -0800)
src/Viewport.test.ts

index 5b106b434538ff84732a5237e2346b30a9940b44..fc2cd1174cf40e052da67e0d87675948da6c559b 100644 (file)
@@ -1,6 +1,11 @@
 import { assert } from 'chai';
 import { Viewport } from './Viewport';
 
+class MockWindow {
+  // Disable refreshLoop in test
+  public requestAnimationFrame() { }
+}
+
 describe('Viewport', () => {
   var terminal;
   var viewportElement;
@@ -11,6 +16,7 @@ describe('Viewport', () => {
   const CHARACTER_HEIGHT = 10;
 
   beforeEach(() => {
+    (<any>global).window = new MockWindow();
     terminal = {
       lines: [],
       rows: 0,
@@ -73,10 +79,14 @@ describe('Viewport', () => {
       terminal.rows = 1;
       assert.equal(scrollAreaElement.style.height, 0 * CHARACTER_HEIGHT + 'px');
       viewport.syncScrollArea();
+      assert.ok(viewport.isRefreshQueued);
+      viewport.refresh();
       assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
       assert.equal(scrollAreaElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
       terminal.lines.push('');
       viewport.syncScrollArea();
+      assert.ok(viewport.isRefreshQueued);
+      viewport.refresh();
       assert.equal(viewportElement.style.height, 1 * CHARACTER_HEIGHT + 'px');
       assert.equal(scrollAreaElement.style.height, 2 * CHARACTER_HEIGHT + 'px');
     });