diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2017-06-27 19:06:41 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-06-27 21:04:55 +0300 |
commit | 42fac10d77f7b5a7dbad2febf1e1b7d5e95ab407 (patch) | |
tree | a02a68e255bdee0333f9d65b09491f3d6f1aa429 /spec | |
parent | b2dd17b2f2c0d02c18d5b413d5fefd59b4c9fed1 (diff) |
Merge branch '34014-submitting-reply-to-existing-diff-discussion-using-cmd-ctrl-enter-submits-twice-and-refreshes-page' into 'master'
Resolve "Submitting reply to existing diff discussion using Cmd/Ctrl+Enter submits twice and refreshes page"
Closes #34014
See merge request !12352
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/behaviors/quick_submit_spec.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/spec/javascripts/behaviors/quick_submit_spec.js b/spec/javascripts/behaviors/quick_submit_spec.js index f56b99f8a16..6dc48f9a293 100644 --- a/spec/javascripts/behaviors/quick_submit_spec.js +++ b/spec/javascripts/behaviors/quick_submit_spec.js @@ -40,16 +40,29 @@ import '~/behaviors/quick_submit'; it('disables input of type submit', function() { const submitButton = $('.js-quick-submit input[type=submit]'); this.textarea.trigger(keydownEvent()); + expect(submitButton).toBeDisabled(); }); it('disables button of type submit', function() { - // button doesn't exist in fixture, add it manually - const submitButton = $('<button type="submit">Submit it</button>'); - submitButton.insertAfter(this.textarea); - + const submitButton = $('.js-quick-submit input[type=submit]'); this.textarea.trigger(keydownEvent()); + expect(submitButton).toBeDisabled(); }); + it('only clicks one submit', function() { + const existingSubmit = $('.js-quick-submit input[type=submit]'); + // Add an extra submit button + const newSubmit = $('<button type="submit">Submit it</button>'); + newSubmit.insertAfter(this.textarea); + + const oldClick = spyOnEvent(existingSubmit, 'click'); + const newClick = spyOnEvent(newSubmit, 'click'); + + this.textarea.trigger(keydownEvent()); + + expect(oldClick).not.toHaveBeenTriggered(); + expect(newClick).toHaveBeenTriggered(); + }); // We cannot stub `navigator.userAgent` for CI's `rake karma` task, so we'll // only run the tests that apply to the current platform if (navigator.userAgent.match(/Macintosh/)) { |