diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/frontend/flash_spec.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/frontend/flash_spec.js')
-rw-r--r-- | spec/frontend/flash_spec.js | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/spec/frontend/flash_spec.js b/spec/frontend/flash_spec.js index 6a5ac76a4d0..28e8522cc12 100644 --- a/spec/frontend/flash_spec.js +++ b/spec/frontend/flash_spec.js @@ -357,27 +357,46 @@ describe('Flash', () => { }); describe('removeFlashClickListener', () => { - beforeEach(() => { - document.body.innerHTML += ` - <div class="flash-container"> - <div class="flash"> - <div class="close-icon js-close-icon"></div> + let el; + + describe('with close icon', () => { + beforeEach(() => { + el = document.createElement('div'); + el.innerHTML = ` + <div class="flash-container"> + <div class="flash"> + <div class="close-icon js-close-icon"></div> + </div> </div> - </div> - `; - }); + `; + }); - it('removes global flash on click', (done) => { - const flashEl = document.querySelector('.flash'); + it('removes global flash on click', (done) => { + removeFlashClickListener(el, false); - removeFlashClickListener(flashEl, false); + el.querySelector('.js-close-icon').click(); - flashEl.querySelector('.js-close-icon').click(); + setImmediate(() => { + expect(document.querySelector('.flash')).toBeNull(); - setImmediate(() => { - expect(document.querySelector('.flash')).toBeNull(); + done(); + }); + }); + }); + + describe('without close icon', () => { + beforeEach(() => { + el = document.createElement('div'); + el.innerHTML = ` + <div class="flash-container"> + <div class="flash"> + </div> + </div> + `; + }); - done(); + it('does not throw', () => { + expect(() => removeFlashClickListener(el, false)).not.toThrow(); }); }); }); |