From c02eea6ad34b17b93bd2e222b71805a9723d3918 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 9 Oct 2016 13:00:51 -0700 Subject: [PATCH] Add tests for scrollDisp --- test/test.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index fc44b31..c24122d 100644 --- a/test/test.js +++ b/test/test.js @@ -88,9 +88,40 @@ describe('xterm.js', function() { }); }); - describe('scrollDisp', function() { - it('should scroll a single line', function() { - assert.equal(xterm.ydisp, -1); + describe('scroll', function() { + describe('scrollDisp', function() { + var startYDisp; + beforeEach(function() { + for (var i = 0; i < xterm.rows * 2; i++) { + xterm.writeln('test'); + } + startYDisp = xterm.rows + 1; + }); + it('should scroll a single line', function() { + assert.equal(xterm.ydisp, startYDisp); + xterm.scrollDisp(-1); + assert.equal(xterm.ydisp, startYDisp - 1); + xterm.scrollDisp(1); + assert.equal(xterm.ydisp, startYDisp); + }); + it('should scroll multiple lines', function() { + assert.equal(xterm.ydisp, startYDisp); + xterm.scrollDisp(-5); + assert.equal(xterm.ydisp, startYDisp - 5); + xterm.scrollDisp(5); + assert.equal(xterm.ydisp, startYDisp); + }); + it('should not scroll beyond the bounds of the buffer', function() { + assert.equal(xterm.ydisp, startYDisp); + xterm.scrollDisp(1); + assert.equal(xterm.ydisp, startYDisp); + for (var i = 0; i < startYDisp; i++) { + xterm.scrollDisp(-1); + } + assert.equal(xterm.ydisp, 0); + xterm.scrollDisp(-1); + assert.equal(xterm.ydisp, 0); + }); }); });