diff options
author | Nick Thomas <nick@gitlab.com> | 2018-11-19 15:03:58 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-12-06 18:58:00 +0000 |
commit | 9395d198f9b9ec59858d2f316e58cda22ab80050 (patch) | |
tree | 0b494120c8d7d59316d590fada95adcbf0ac23f2 /spec/javascripts/lib | |
parent | 79b44c16ccf3827eba6b168aae6c395ac3f3df17 (diff) | |
download | gitlab-ce-9395d198f9b9ec59858d2f316e58cda22ab80050.tar.gz |
Use BFG object maps to clean projects
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/file_upload_spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/file_upload_spec.js b/spec/javascripts/lib/utils/file_upload_spec.js new file mode 100644 index 00000000000..92c9cc70aaf --- /dev/null +++ b/spec/javascripts/lib/utils/file_upload_spec.js @@ -0,0 +1,36 @@ +import fileUpload from '~/lib/utils/file_upload'; + +describe('File upload', () => { + beforeEach(() => { + setFixtures(` + <form> + <button class="js-button" type="button">Click me!</button> + <input type="text" class="js-input" /> + <span class="js-filename"></span> + </form> + `); + + 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'); + + input.value = 'path/to/file/index.js'; + + input.dispatchEvent(new CustomEvent('change')); + + expect(document.querySelector('.js-filename').textContent).toEqual('index.js'); + }); +}); |