diff options
author | Nick Thomas <nick@gitlab.com> | 2019-02-07 12:27:08 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-02-07 12:27:08 +0000 |
commit | 041316636b594c15f3fde9839354e3f1309ec763 (patch) | |
tree | 2193705968cb463a2923557b29e710fb4ce47ff8 /spec/javascripts/lib | |
parent | 4b74da30a513ada6532d1ef7ec7bde79d0c9a0f6 (diff) | |
parent | 6b466e38738e3e6bcf4b13cca1e5f680daa43ae4 (diff) | |
download | gitlab-ce-041316636b594c15f3fde9839354e3f1309ec763.tar.gz |
Merge branch 'fix-repo-settings-file-upload-error' into 'master'
Fix bug causing repository mirror settings UI to break
Closes #55134
See merge request gitlab-org/gitlab-ce!23712
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/file_upload_spec.js | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/spec/javascripts/lib/utils/file_upload_spec.js b/spec/javascripts/lib/utils/file_upload_spec.js index 92c9cc70aaf..8f7092f63de 100644 --- a/spec/javascripts/lib/utils/file_upload_spec.js +++ b/spec/javascripts/lib/utils/file_upload_spec.js @@ -9,28 +9,56 @@ describe('File upload', () => { <span class="js-filename"></span> </form> `); + }); + + describe('when there is a matching button and input', () => { + beforeEach(() => { + fileUpload('.js-button', '.js-input'); + }); + + it('clicks file input after clicking button', () => { + const btn = document.querySelector('.js-button'); + const input = document.querySelector('.js-input'); + + spyOn(input, 'click'); + + btn.click(); + + expect(input.click).toHaveBeenCalled(); + }); + + it('updates file name text', () => { + const input = document.querySelector('.js-input'); - fileUpload('.js-button', '.js-input'); + input.value = 'path/to/file/index.js'; + + input.dispatchEvent(new CustomEvent('change')); + + expect(document.querySelector('.js-filename').textContent).toEqual('index.js'); + }); }); - it('clicks file input after clicking button', () => { - const btn = document.querySelector('.js-button'); + it('fails gracefully when there is no matching button', () => { const input = document.querySelector('.js-input'); + const btn = document.querySelector('.js-button'); + fileUpload('.js-not-button', '.js-input'); spyOn(input, 'click'); btn.click(); - expect(input.click).toHaveBeenCalled(); + expect(input.click).not.toHaveBeenCalled(); }); - it('updates file name text', () => { + it('fails gracefully when there is no matching input', () => { const input = document.querySelector('.js-input'); + const btn = document.querySelector('.js-button'); + fileUpload('.js-button', '.js-not-input'); - input.value = 'path/to/file/index.js'; + spyOn(input, 'click'); - input.dispatchEvent(new CustomEvent('change')); + btn.click(); - expect(document.querySelector('.js-filename').textContent).toEqual('index.js'); + expect(input.click).not.toHaveBeenCalled(); }); }); |