rewrote to async
This commit is contained in:
+37
-10
@@ -86,22 +86,32 @@ describe('term.js addons', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe(`keypress (including 'key' event)`, () => {
|
describe(`keypress (including 'key' event)`, () => {
|
||||||
it('should receive a string and event object', () => {
|
it('should receive a string and event object', (done) => {
|
||||||
|
let steps = 0;
|
||||||
|
|
||||||
|
const finish = () => {
|
||||||
|
if ((++steps) === 2) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const evKeyPress = <KeyboardEvent>{
|
const evKeyPress = <KeyboardEvent>{
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keypress',
|
type: 'keypress',
|
||||||
keyCode: 77
|
keyCode: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
term.on('keypress', (key, event) => {
|
term.on('keypress', (key, event) => {
|
||||||
assert.equal(typeof key, 'string');
|
assert.equal(typeof key, 'string');
|
||||||
expect(event).to.be.an.instanceof(Object);
|
expect(event).to.be.an.instanceof(Object);
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.on('key', (key, event) => {
|
term.on('key', (key, event) => {
|
||||||
assert.equal(typeof key, 'string');
|
assert.equal(typeof key, 'string');
|
||||||
expect(event).to.be.an.instanceof(Object);
|
expect(event).to.be.an.instanceof(Object);
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.keyPress(evKeyPress);
|
term.keyPress(evKeyPress);
|
||||||
@@ -109,22 +119,31 @@ describe('term.js addons', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe(`keydown (including 'key' event)`, () => {
|
describe(`keydown (including 'key' event)`, () => {
|
||||||
it('should receive a string and event object', () => {
|
it(`should receive an event object for 'keydown' and a string and event object for 'key'`, (done) => {
|
||||||
|
let steps = 0;
|
||||||
|
|
||||||
|
const finish = () => {
|
||||||
|
if ((++steps) === 2) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const evKeyDown = <KeyboardEvent>{
|
const evKeyDown = <KeyboardEvent>{
|
||||||
preventDefault: () => { },
|
preventDefault: () => { },
|
||||||
stopPropagation: () => { },
|
stopPropagation: () => { },
|
||||||
type: 'keydown',
|
type: 'keydown',
|
||||||
keyCode: 77
|
keyCode: 13
|
||||||
};
|
};
|
||||||
|
|
||||||
term.on('keydown', (key, event) => {
|
term.on('keydown', (event) => {
|
||||||
assert.equal(typeof key, 'string');
|
|
||||||
expect(event).to.be.an.instanceof(Object);
|
expect(event).to.be.an.instanceof(Object);
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.on('key', (key, event) => {
|
term.on('key', (key, event) => {
|
||||||
assert.equal(typeof key, 'string');
|
assert.equal(typeof key, 'string');
|
||||||
expect(event).to.be.an.instanceof(Object);
|
expect(event).to.be.an.instanceof(Object);
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.keyDown(evKeyDown);
|
term.keyDown(evKeyDown);
|
||||||
@@ -132,41 +151,49 @@ describe('term.js addons', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('refresh', () => {
|
describe('refresh', () => {
|
||||||
it('should receive an object: {start: number, end: number}', () => {
|
it('should receive an object: {start: number, end: number}', (done) => {
|
||||||
term.on('refresh', (data) => {
|
term.on('refresh', (data) => {
|
||||||
expect(data).to.have.keys(['start', 'end']);
|
expect(data).to.have.keys(['start', 'end']);
|
||||||
assert.equal(typeof data.start, 'number');
|
assert.equal(typeof data.start, 'number');
|
||||||
assert.equal(typeof data.end, 'number');
|
assert.equal(typeof data.end, 'number');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.refresh(0, term.rows - 1);
|
term.refresh(0, term.rows - 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('resize', () => {
|
describe('resize', () => {
|
||||||
it('should receive an object: {cols: number, rows: number}', () => {
|
it('should receive an object: {cols: number, rows: number}', (done) => {
|
||||||
term.on('resize', (data) => {
|
term.on('resize', (data) => {
|
||||||
expect(data).to.have.keys(['cols', 'rows']);
|
expect(data).to.have.keys(['cols', 'rows']);
|
||||||
assert.equal(typeof data.cols, 'number');
|
assert.equal(typeof data.cols, 'number');
|
||||||
assert.equal(typeof data.rows, 'number');
|
assert.equal(typeof data.rows, 'number');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.resize(1, 1);
|
term.resize(1, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('scroll', () => {
|
describe('scroll', () => {
|
||||||
it('should receive a number', () => {
|
it('should receive a number', (done) => {
|
||||||
term.on('scroll', (ydisp) => {
|
term.on('scroll', (ydisp) => {
|
||||||
assert.equal(typeof ydisp, 'number');
|
assert.equal(typeof ydisp, 'number');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.scroll();
|
term.scroll();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('title', () => {
|
describe('title', () => {
|
||||||
it('should receive a string', () => {
|
it('should receive a string', (done) => {
|
||||||
term.on('title', (title) => {
|
term.on('title', (title) => {
|
||||||
assert.equal(typeof title, 'string');
|
assert.equal(typeof title, 'string');
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
term.handleTitle('title');
|
term.handleTitle('title');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user