diff options
author | Sam Bigelow <sbigelow@gitlab.com> | 2018-11-27 13:05:25 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-11-27 13:05:25 +0300 |
commit | 5b7b482274d0b1e6b25ae18410d7a3a2dc3670a0 (patch) | |
tree | 19ebca95bd2846bce521148c7460c3e5714084ec /spec/javascripts/blob_edit | |
parent | 1fae9f36dd994ca5231cd7fe46e365d352a76b0a (diff) |
Resolve "Warn in Web Editor when user navigates away"
Diffstat (limited to 'spec/javascripts/blob_edit')
-rw-r--r-- | spec/javascripts/blob_edit/blob_bundle_spec.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/javascripts/blob_edit/blob_bundle_spec.js b/spec/javascripts/blob_edit/blob_bundle_spec.js new file mode 100644 index 00000000000..759d170af77 --- /dev/null +++ b/spec/javascripts/blob_edit/blob_bundle_spec.js @@ -0,0 +1,30 @@ +import blobBundle from '~/blob_edit/blob_bundle'; +import $ from 'jquery'; + +window.ace = { + config: { + set: () => {}, + loadModule: () => {}, + }, + edit: () => ({ focus: () => {} }), +}; + +describe('EditBlob', () => { + beforeEach(() => { + setFixtures(` + <div class="js-edit-blob-form"> + <button class="js-commit-button"></button> + </div>`); + blobBundle(); + }); + + it('sets the window beforeunload listener to a function returning a string', () => { + expect(window.onbeforeunload()).toBe(''); + }); + + it('removes beforeunload listener if commit button is clicked', () => { + $('.js-commit-button').click(); + + expect(window.onbeforeunload).toBeNull(); + }); +}); |