diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/droplab/hook_spec.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/droplab/hook_spec.js')
-rw-r--r-- | spec/frontend/droplab/hook_spec.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/spec/frontend/droplab/hook_spec.js b/spec/frontend/droplab/hook_spec.js new file mode 100644 index 00000000000..11488cab521 --- /dev/null +++ b/spec/frontend/droplab/hook_spec.js @@ -0,0 +1,94 @@ +import Hook from '~/droplab/hook'; +import DropDown from '~/droplab/drop_down'; + +jest.mock('~/droplab/drop_down', () => jest.fn()); + +describe('Hook', () => { + let testContext; + + beforeEach(() => { + testContext = {}; + }); + + describe('class constructor', () => { + beforeEach(() => { + testContext.trigger = { id: 'id' }; + testContext.list = {}; + testContext.plugins = {}; + testContext.config = {}; + + testContext.hook = new Hook( + testContext.trigger, + testContext.list, + testContext.plugins, + testContext.config, + ); + }); + + it('should set .trigger', () => { + expect(testContext.hook.trigger).toBe(testContext.trigger); + }); + + it('should set .list', () => { + expect(testContext.hook.list).toEqual({}); + }); + + it('should call DropDown constructor', () => { + expect(DropDown).toHaveBeenCalledWith(testContext.list, testContext.config); + }); + + it('should set .type', () => { + expect(testContext.hook.type).toBe('Hook'); + }); + + it('should set .event', () => { + expect(testContext.hook.event).toBe('click'); + }); + + it('should set .plugins', () => { + expect(testContext.hook.plugins).toBe(testContext.plugins); + }); + + it('should set .config', () => { + expect(testContext.hook.config).toBe(testContext.config); + }); + + it('should set .id', () => { + expect(testContext.hook.id).toBe(testContext.trigger.id); + }); + + describe('if config argument is undefined', () => { + beforeEach(() => { + testContext.config = undefined; + + testContext.hook = new Hook( + testContext.trigger, + testContext.list, + testContext.plugins, + testContext.config, + ); + }); + + it('should set .config to an empty object', () => { + expect(testContext.hook.config).toEqual({}); + }); + }); + + describe('if plugins argument is undefined', () => { + beforeEach(() => { + testContext.plugins = undefined; + + testContext.hook = new Hook( + testContext.trigger, + testContext.list, + testContext.plugins, + testContext.config, + ); + }); + + it('should set .plugins to an empty array', () => { + expect(testContext.hook.plugins).toEqual([]); + }); + }); + }); +}); |