import { wcwidth } from './InputHandler';
describe('InputHandler', () => {
+ describe('save and restore cursor', () => {
+ let terminal = { buffer: { x: 1, y: 2 } };
+ let inputHandler = new InputHandler(terminal);
+ // Save cursor position
+ inputHandler.saveCursor([]);
+ assert.equal(terminal.buffer.x, 1);
+ assert.equal(terminal.buffer.y, 2);
+ // Change cursor position
+ terminal.buffer.x = 10;
+ terminal.buffer.y = 20;
+ // Restore cursor position
+ inputHandler.restoreCursor([]);
+ assert.equal(terminal.buffer.x, 1);
+ assert.equal(terminal.buffer.y, 2);
+ });
describe('setCursorStyle', () => {
it('should call Terminal.setOption with correct params', () => {
let options = {};
})({nul: 0, control: 0}); // configurable options
describe('wcwidth', () => {
- it('same as old implementation for BMP and individual higher', () => {
+ it('same as old implementation for BMP and individual higher', (done) => {
for (let i = 0; i < 65536; ++i)
assert.equal(wcwidth(i), old_wcwidth(i));
// test some individual higher to fullfill branching
assert.equal(wcwidth(0x10A01), old_wcwidth(0x10A01));
assert.equal(wcwidth(0x30000), old_wcwidth(0x30000));
assert.equal(wcwidth(0x3fffe), old_wcwidth(0x3fffe));
- });
+ done();
+ }).timeout(3000);
+ /*
it('new is at least 5 times faster', () => {
let start_new = new Date().getTime();
let x = 0;
for (let i = 0; i < 65536; ++i)
y = old_wcwidth(i);
let end_old = new Date().getTime();
- //console.log((end_new - start_new));
- //console.log((end_old - start_old));
+ // console.log((end_new - start_new));
+ // console.log((end_old - start_old));
assert.equal(((end_new - start_new) * 5 < (end_old - start_old)), true);
});
+ */
});