2017-04-07 09:57:03 -04:00
|
|
|
import Hook from '~/droplab/hook';
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
describe('Hook', function() {
|
|
|
|
describe('class constructor', function() {
|
|
|
|
beforeEach(function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
this.trigger = { id: 'id' };
|
|
|
|
this.list = {};
|
|
|
|
this.plugins = {};
|
|
|
|
this.config = {};
|
|
|
|
this.dropdown = {};
|
|
|
|
|
2018-04-13 18:19:09 -04:00
|
|
|
this.dropdownConstructor = spyOnDependency(Hook, 'DropDown').and.returnValue(this.dropdown);
|
2017-04-07 09:57:03 -04:00
|
|
|
|
|
|
|
this.hook = new Hook(this.trigger, this.list, this.plugins, this.config);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .trigger', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.trigger).toBe(this.trigger);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .list', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.list).toBe(this.dropdown);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should call DropDown constructor', function() {
|
2018-04-13 18:19:09 -04:00
|
|
|
expect(this.dropdownConstructor).toHaveBeenCalledWith(this.list, this.config);
|
2017-04-07 09:57:03 -04:00
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .type', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.type).toBe('Hook');
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .event', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.event).toBe('click');
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .plugins', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.plugins).toBe(this.plugins);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .config', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.config).toBe(this.config);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .id', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.id).toBe(this.trigger.id);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
describe('if config argument is undefined', function() {
|
|
|
|
beforeEach(function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
this.config = undefined;
|
|
|
|
|
|
|
|
this.hook = new Hook(this.trigger, this.list, this.plugins, this.config);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .config to an empty object', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.config).toEqual({});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
describe('if plugins argument is undefined', function() {
|
|
|
|
beforeEach(function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
this.plugins = undefined;
|
|
|
|
|
|
|
|
this.hook = new Hook(this.trigger, this.list, this.plugins, this.config);
|
|
|
|
});
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
it('should set .plugins to an empty array', function() {
|
2017-04-07 09:57:03 -04:00
|
|
|
expect(this.hook.plugins).toEqual([]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|