Commit 128d8b61 authored by winniehell's avatar winniehell

Replace static fixture for behaviors/quick_submit_spec.js (!9086)

parent d4317e4d
---
title: Replace static fixture for behaviors/quick_submit_spec.js
merge_request: 9086
author: winniehell
...@@ -5,9 +5,9 @@ require('~/behaviors/quick_submit'); ...@@ -5,9 +5,9 @@ require('~/behaviors/quick_submit');
(function() { (function() {
describe('Quick Submit behavior', function() { describe('Quick Submit behavior', function() {
var keydownEvent; var keydownEvent;
preloadFixtures('static/behaviors/quick_submit.html.raw'); preloadFixtures('issues/open-issue.html.raw');
beforeEach(function() { beforeEach(function() {
loadFixtures('static/behaviors/quick_submit.html.raw'); loadFixtures('issues/open-issue.html.raw');
$('form').submit(function(e) { $('form').submit(function(e) {
// Prevent a form submit from moving us off the testing page // Prevent a form submit from moving us off the testing page
return e.preventDefault(); return e.preventDefault();
...@@ -37,10 +37,18 @@ require('~/behaviors/quick_submit'); ...@@ -37,10 +37,18 @@ require('~/behaviors/quick_submit');
})); }));
return expect(this.spies.submit).not.toHaveBeenTriggered(); return expect(this.spies.submit).not.toHaveBeenTriggered();
}); });
it('disables submit buttons', function() { it('disables input of type submit', function() {
const submitButton = $('.js-quick-submit input[type=submit]');
this.textarea.trigger(keydownEvent()); this.textarea.trigger(keydownEvent());
expect($('input[type=submit]')).toBeDisabled(); expect(submitButton).toBeDisabled();
return expect($('button[type=submit]')).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);
this.textarea.trigger(keydownEvent());
expect(submitButton).toBeDisabled();
}); });
// We cannot stub `navigator.userAgent` for CI's `rake karma` task, so we'll // We cannot stub `navigator.userAgent` for CI's `rake karma` task, so we'll
// only run the tests that apply to the current platform // only run the tests that apply to the current platform
......
%form.js-quick-submit{ action: '/foo' }
%textarea
%input{ type: 'submit'} Submit
%button.btn{ type: 'submit' } Submit
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment