Commit 556ef5ed authored by Phil Hughes's avatar Phil Hughes

spec fixes

parent 44d3745e
...@@ -32,9 +32,9 @@ export default class GlFieldErrors { ...@@ -32,9 +32,9 @@ export default class GlFieldErrors {
const $form = $(e.currentTarget); const $form = $(e.currentTarget);
if (!$form.attr('novalidate')) { if (!$form.attr('novalidate')) {
if (!event.currentTarget.checkValidity()) { if (!e.currentTarget.checkValidity()) {
event.preventDefault(); e.preventDefault();
event.stopPropagation(); e.stopPropagation();
} }
} }
} }
......
...@@ -558,7 +558,7 @@ export default class Notes { ...@@ -558,7 +558,7 @@ export default class Notes {
*/ */
setupNoteForm(form) { setupNoteForm(form) {
var textarea, key; var textarea, key;
new GLForm(form, this.enableGFM); this.glForm = new GLForm(form, this.enableGFM);
textarea = form.find('.js-note-text'); textarea = form.find('.js-note-text');
key = [ key = [
'Note', 'Note',
...@@ -1153,7 +1153,7 @@ export default class Notes { ...@@ -1153,7 +1153,7 @@ export default class Notes {
var targetId = $originalContentEl.data('target-id'); var targetId = $originalContentEl.data('target-id');
var targetType = $originalContentEl.data('target-type'); var targetType = $originalContentEl.data('target-type');
new GLForm($editForm.find('form'), this.enableGFM); this.glForm = new GLForm($editForm.find('form'), this.enableGFM);
$editForm.find('form') $editForm.find('form')
.attr('action', postUrl) .attr('action', postUrl)
......
import autosize from 'vendor/autosize'; import autosize from 'vendor/autosize';
import '~/gl_form'; import GLForm from '~/gl_form';
import '~/lib/utils/text_utility'; import '~/lib/utils/text_utility';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
window.autosize = autosize; window.autosize = autosize;
describe('GLForm', () => { describe('GLForm', () => {
const global = window.gl || (window.gl = {});
const GLForm = global.GLForm;
it('should be defined in the global scope', () => {
expect(GLForm).toBeDefined();
});
describe('when instantiated', function () { describe('when instantiated', function () {
beforeEach((done) => { beforeEach((done) => {
this.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>'); this.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>');
......
...@@ -426,19 +426,17 @@ import '~/notes'; ...@@ -426,19 +426,17 @@ import '~/notes';
}); });
describe('putEditFormInPlace', () => { describe('putEditFormInPlace', () => {
it('should call gl.GLForm with GFM parameter passed through', () => { it('should call GLForm with GFM parameter passed through', () => {
spyOn(gl, 'GLForm'); const notes = new Notes('', []);
const $el = $(`
<div>
<form></form>
</div>
`);
const $el = jasmine.createSpyObj('$form', ['find', 'closest']); notes.putEditFormInPlace($el);
$el.find.and.returnValue($('<div>'));
$el.closest.and.returnValue($('<div>'));
Notes.prototype.putEditFormInPlace.call({ expect(notes.glForm.enableGFM).toBeTruthy();
getEditFormSelector: () => '',
enableGFM: true
}, $el);
expect(gl.GLForm).toHaveBeenCalledWith(jasmine.any(Object), true);
}); });
}); });
......
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