Add tests

This commit is contained in:
Daniel Imms
2016-07-15 16:31:57 -07:00
parent 06a3aa6cf8
commit 9cb5b005bb
2 changed files with 27 additions and 1 deletions
+26
View File
@@ -57,6 +57,32 @@ describe('xterm.js', function() {
});
});
describe('attachCustomEventHandler', function () {
var evKeyDown = {
preventDefault: function() {},
stopPropagation: function() {},
type: 'keydown'
}
beforeEach(function() {
xterm.handler = function() {};
xterm.showCursor = function() {};
xterm.clearSelection = function() {};
});
it('should process the keydown event based on what the handler returns', function () {
assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), true);
xterm.attachCustomKeydownHandler(function (ev) {
return ev.keyCode === 77;
});
assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), true);
xterm.attachCustomKeydownHandler(function (ev) {
return ev.keyCode !== 77;
});
assert.equal(xterm.keyDown(Object.assign({}, evKeyDown, { keyCode: 77 })), false);
});
});
describe('evaluateCopiedTextProcessing', function () {
it('should strip trailing whitespaces and replace nbsps with spaces', function () {
var nonBreakingSpace = String.fromCharCode(160),