CLient side unit test for dialog onKeypress()
This commit is contained in:
parent
aec32f5e4a
commit
c341009489
|
@ -158,4 +158,28 @@ describe('Component vnDialog', () => {
|
|||
expect(controller.hide).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('onKeypress()', () => {
|
||||
it(`should call hide() if the key pressed equal the code 27`, () => {
|
||||
let controller = $componentController('vnDialog', {$element});
|
||||
controller.element = document.createElement('div');
|
||||
let event = {target: controller.element};
|
||||
event.keyCode = 27;
|
||||
spyOn(controller, 'hide');
|
||||
controller.onKeypress(event);
|
||||
|
||||
expect(controller.hide).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it(`should't call hide() as the key pressed equal the code 999`, () => {
|
||||
let controller = $componentController('vnDialog', {$element});
|
||||
controller.element = document.createElement('div');
|
||||
let event = {target: controller.element};
|
||||
event.keyCode = 999;
|
||||
spyOn(controller, 'hide');
|
||||
controller.onKeypress(event);
|
||||
|
||||
expect(controller.hide).not.toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue