diff options
author | winh <winnie@gitlab.com> | 2017-06-27 10:47:58 +0200 |
---|---|---|
committer | winh <winnie@gitlab.com> | 2017-06-27 16:31:01 +0200 |
commit | abfb59109d5b7ff874af9003980779d1a61a0064 (patch) | |
tree | e2d8f5e32cabd39d7e88b24d9e017f2ce9bc4e45 | |
parent | ad3843aee14abb36e0f4a7ede7210f26ed4879c9 (diff) | |
download | gitlab-ce-abfb59109d5b7ff874af9003980779d1a61a0064.tar.gz |
Add failing test for #34141
-rw-r--r-- | spec/javascripts/filtered_search/dropdown_user_spec.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/javascripts/filtered_search/dropdown_user_spec.js b/spec/javascripts/filtered_search/dropdown_user_spec.js index f7708301b6e..0132f4b7c93 100644 --- a/spec/javascripts/filtered_search/dropdown_user_spec.js +++ b/spec/javascripts/filtered_search/dropdown_user_spec.js @@ -66,4 +66,38 @@ describe('Dropdown User', () => { window.gon = {}; }); }); + + describe('hideCurrentUser', () => { + const fixtureTemplate = 'issues/issue_list.html.raw'; + preloadFixtures(fixtureTemplate); + + let dropdown; + let authorFilterDropdownElement; + + beforeEach(() => { + loadFixtures(fixtureTemplate); + authorFilterDropdownElement = document.querySelector('#js-dropdown-author'); + const dummyInput = document.createElement('div'); + dropdown = new gl.DropdownUser(null, authorFilterDropdownElement, dummyInput); + }); + + const findCurrentUserElement = () => authorFilterDropdownElement.querySelector('.js-current-user'); + + it('hides the current user from dropdown', () => { + const currentUserElement = findCurrentUserElement(); + expect(currentUserElement).not.toBe(null); + + dropdown.hideCurrentUser(); + + expect(currentUserElement.classList).toContain('hidden'); + }); + + it('does nothing if no user is logged in', () => { + const currentUserElement = findCurrentUserElement(); + currentUserElement.parentNode.removeChild(currentUserElement); + expect(findCurrentUserElement()).toBe(null); + + dropdown.hideCurrentUser(); + }); + }); }); |