client side unit test for dialog onBackgroundMouseDown()
This commit is contained in:
parent
022450000e
commit
aec32f5e4a
|
@ -122,4 +122,40 @@ describe('Component vnDialog', () => {
|
||||||
expect(controller.fireResponse).toHaveBeenCalledWith('I am the response!');
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue