diff options
Diffstat (limited to 'spec/frontend/namespace_select_spec.js')
-rw-r--r-- | spec/frontend/namespace_select_spec.js | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/spec/frontend/namespace_select_spec.js b/spec/frontend/namespace_select_spec.js deleted file mode 100644 index a38508dd601..00000000000 --- a/spec/frontend/namespace_select_spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; -import NamespaceSelect from '~/namespace_select'; - -jest.mock('~/deprecated_jquery_dropdown'); - -describe('NamespaceSelect', () => { - it('initializes deprecatedJQueryDropdown', () => { - const dropdown = document.createElement('div'); - - // eslint-disable-next-line no-new - new NamespaceSelect({ dropdown }); - - expect(initDeprecatedJQueryDropdown).toHaveBeenCalled(); - }); - - describe('as input', () => { - let deprecatedJQueryDropdownOptions; - - beforeEach(() => { - const dropdown = document.createElement('div'); - // eslint-disable-next-line no-new - new NamespaceSelect({ dropdown }); - [[, deprecatedJQueryDropdownOptions]] = initDeprecatedJQueryDropdown.mock.calls; - }); - - it('prevents click events', () => { - const dummyEvent = new Event('dummy'); - jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {}); - - // expect(foo).toContain('test'); - deprecatedJQueryDropdownOptions.clicked({ e: dummyEvent }); - - expect(dummyEvent.preventDefault).toHaveBeenCalled(); - }); - }); - - describe('as filter', () => { - let deprecatedJQueryDropdownOptions; - - beforeEach(() => { - const dropdown = document.createElement('div'); - dropdown.dataset.isFilter = 'true'; - // eslint-disable-next-line no-new - new NamespaceSelect({ dropdown }); - [[, deprecatedJQueryDropdownOptions]] = initDeprecatedJQueryDropdown.mock.calls; - }); - - it('does not prevent click events', () => { - const dummyEvent = new Event('dummy'); - jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {}); - - deprecatedJQueryDropdownOptions.clicked({ e: dummyEvent }); - - expect(dummyEvent.preventDefault).not.toHaveBeenCalled(); - }); - - it('sets URL of dropdown items', () => { - const dummyNamespace = { id: 'eal' }; - - const itemUrl = deprecatedJQueryDropdownOptions.url(dummyNamespace); - - expect(itemUrl).toContain(`namespace_id=${dummyNamespace.id}`); - }); - }); -}); |