client side unit test for dialog onBackgroundMouseDown()

This commit is contained in:
Carlos 2017-10-06 16:30:51 +02:00
parent 022450000e
commit aec32f5e4a
1 changed files with 36 additions and 0 deletions

View File

@ -122,4 +122,40 @@ describe('Component vnDialog', () => {
expect(controller.fireResponse).toHaveBeenCalledWith('I am the response!');
});
});
describe('onDialogMouseDown()', () => {
it(`should set controller's lastEvent property`, () => {
let controller = $componentController('vnDialog', {$element});
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.onDialogMouseDown(event);
expect(controller.lastEvent).toEqual(event);
});
});
describe('onBackgroundMouseDown()', () => {
it(`shouldn't call hide() function as event equals lastEvent`, () => {
let controller = $componentController('vnDialog', {$element});
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.lastEvent = event;
spyOn(controller, 'hide');
controller.onBackgroundMouseDown(event);
expect(controller.hide).not.toHaveBeenCalledWith();
});
it(`should call hide() function as event doesn't equal lastEvent`, () => {
let controller = $componentController('vnDialog', {$element});
controller.element = document.createElement('div');
let event = {target: controller.element};
controller.lastEvent = event;
controller.lastEvent = 'the singularity event!';
spyOn(controller, 'hide');
controller.onBackgroundMouseDown(event);
expect(controller.hide).toHaveBeenCalledWith();
});
});
});