diff options
author | Johann Hubert Sonntagbauer <johann.sonntagbauer@gmail.com> | 2018-10-09 21:03:09 +0300 |
---|---|---|
committer | Johann Hubert Sonntagbauer <johann.sonntagbauer@gmail.com> | 2018-10-17 07:57:29 +0300 |
commit | 6f5723a169b5d400c136dbd844fc54c68e5f8563 (patch) | |
tree | e7bad2648366ed5943293655a0abe23367e869a6 /spec/javascripts/behaviors | |
parent | 28d412e5b2b8499fba22e8fabb1d44f44449228e (diff) |
enable jasmine/new-line-before-expect
Diffstat (limited to 'spec/javascripts/behaviors')
6 files changed, 30 insertions, 4 deletions
diff --git a/spec/javascripts/behaviors/autosize_spec.js b/spec/javascripts/behaviors/autosize_spec.js index c411c5174fb..59abae479d4 100644 --- a/spec/javascripts/behaviors/autosize_spec.js +++ b/spec/javascripts/behaviors/autosize_spec.js @@ -12,6 +12,7 @@ describe('Autosize behavior', () => { it('does not overwrite the resize property', () => { load(); + expect($('textarea')).toHaveCss({ resize: 'vertical', }); diff --git a/spec/javascripts/behaviors/copy_as_gfm_spec.js b/spec/javascripts/behaviors/copy_as_gfm_spec.js index c2db81c6ce4..f0b4fa63f71 100644 --- a/spec/javascripts/behaviors/copy_as_gfm_spec.js +++ b/spec/javascripts/behaviors/copy_as_gfm_spec.js @@ -29,6 +29,7 @@ describe('CopyAsGFM', () => { it('wraps pasted code when not already in code tags', () => { spyOn(window.gl.utils, 'insertText').and.callFake((el, textFunc) => { const insertedText = textFunc('This is code: ', ''); + expect(insertedText).toEqual('`code`'); }); @@ -38,6 +39,7 @@ describe('CopyAsGFM', () => { it('does not wrap pasted code when already in code tags', () => { spyOn(window.gl.utils, 'insertText').and.callFake((el, textFunc) => { const insertedText = textFunc('This is code: `', '`'); + expect(insertedText).toEqual('code'); }); @@ -86,6 +88,7 @@ describe('CopyAsGFM', () => { simulateCopy(); const expectedGFM = '- List Item1\n- List Item2'; + expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM); }); @@ -95,6 +98,7 @@ describe('CopyAsGFM', () => { simulateCopy(); const expectedGFM = '1. List Item1\n1. List Item2'; + expect(clipboardData.setData).toHaveBeenCalledWith('text/x-gfm', expectedGFM); }); }); diff --git a/spec/javascripts/behaviors/quick_submit_spec.js b/spec/javascripts/behaviors/quick_submit_spec.js index b3a5eac8982..1fbc1f7a8e8 100644 --- a/spec/javascripts/behaviors/quick_submit_spec.js +++ b/spec/javascripts/behaviors/quick_submit_spec.js @@ -30,6 +30,7 @@ describe('Quick Submit behavior', function () { keyCode: 32, }), ); + expect(this.spies.submit).not.toHaveBeenTriggered(); }); @@ -40,6 +41,7 @@ describe('Quick Submit behavior', function () { metaKey: false, }), ); + expect(this.spies.submit).not.toHaveBeenTriggered(); }); @@ -49,6 +51,7 @@ describe('Quick Submit behavior', function () { repeat: true, }), ); + expect(this.spies.submit).not.toHaveBeenTriggered(); }); @@ -86,7 +89,8 @@ describe('Quick Submit behavior', function () { describe('In Macintosh', () => { it('responds to Meta+Enter', () => { this.textarea.trigger(keydownEvent()); - return expect(this.spies.submit).toHaveBeenTriggered(); + + expect(this.spies.submit).toHaveBeenTriggered(); }); it('excludes other modifier keys', () => { @@ -105,13 +109,15 @@ describe('Quick Submit behavior', function () { shiftKey: true, }), ); - return expect(this.spies.submit).not.toHaveBeenTriggered(); + + expect(this.spies.submit).not.toHaveBeenTriggered(); }); }); } else { it('responds to Ctrl+Enter', () => { this.textarea.trigger(keydownEvent()); - return expect(this.spies.submit).toHaveBeenTriggered(); + + expect(this.spies.submit).toHaveBeenTriggered(); }); it('excludes other modifier keys', () => { @@ -130,7 +136,8 @@ describe('Quick Submit behavior', function () { shiftKey: true, }), ); - return expect(this.spies.submit).not.toHaveBeenTriggered(); + + expect(this.spies.submit).not.toHaveBeenTriggered(); }); } }); diff --git a/spec/javascripts/behaviors/requires_input_spec.js b/spec/javascripts/behaviors/requires_input_spec.js index a434949b9da..5d1cc374573 100644 --- a/spec/javascripts/behaviors/requires_input_spec.js +++ b/spec/javascripts/behaviors/requires_input_spec.js @@ -12,33 +12,39 @@ describe('requiresInput', () => { it('disables submit when any field is required', () => { $('.js-requires-input').requiresInput(); + expect(submitButton).toBeDisabled(); }); it('enables submit when no field is required', () => { $('*[required=required]').prop('required', false); $('.js-requires-input').requiresInput(); + expect(submitButton).not.toBeDisabled(); }); it('enables submit when all required fields are pre-filled', () => { $('*[required=required]').remove(); $('.js-requires-input').requiresInput(); + expect($('.submit')).not.toBeDisabled(); }); it('enables submit when all required fields receive input', () => { $('.js-requires-input').requiresInput(); $('#required1').val('input1').change(); + expect(submitButton).toBeDisabled(); $('#optional1').val('input1').change(); + expect(submitButton).toBeDisabled(); $('#required2').val('input2').change(); $('#required3').val('input3').change(); $('#required4').val('input4').change(); $('#required5').val('1').change(); + expect($('.submit')).not.toBeDisabled(); }); }); diff --git a/spec/javascripts/behaviors/secret_values_spec.js b/spec/javascripts/behaviors/secret_values_spec.js index 95122fcf30f..ed42fc099c1 100644 --- a/spec/javascripts/behaviors/secret_values_spec.js +++ b/spec/javascripts/behaviors/secret_values_spec.js @@ -130,6 +130,7 @@ describe('setupSecretValues', () => { values.forEach((value) => { expect(value.classList.contains('hide')).toEqual(true); }); + expect(placeholders.length).toEqual(3); placeholders.forEach((placeholder) => { expect(placeholder.classList.contains('hide')).toEqual(false); @@ -148,6 +149,7 @@ describe('setupSecretValues', () => { values.forEach((value) => { expect(value.classList.contains('hide')).toEqual(false); }); + expect(placeholders.length).toEqual(3); placeholders.forEach((placeholder) => { expect(placeholder.classList.contains('hide')).toEqual(true); @@ -159,6 +161,7 @@ describe('setupSecretValues', () => { values.forEach((value) => { expect(value.classList.contains('hide')).toEqual(true); }); + expect(placeholders.length).toEqual(3); placeholders.forEach((placeholder) => { expect(placeholder.classList.contains('hide')).toEqual(false); @@ -184,6 +187,7 @@ describe('setupSecretValues', () => { values.forEach((value) => { expect(value.classList.contains('hide')).toEqual(false); }); + expect(placeholders.length).toEqual(4); placeholders.forEach((placeholder) => { expect(placeholder.classList.contains('hide')).toEqual(true); @@ -195,6 +199,7 @@ describe('setupSecretValues', () => { values.forEach((value) => { expect(value.classList.contains('hide')).toEqual(true); }); + expect(placeholders.length).toEqual(4); placeholders.forEach((placeholder) => { expect(placeholder.classList.contains('hide')).toEqual(false); diff --git a/spec/javascripts/behaviors/shortcuts/shortcuts_issuable_spec.js b/spec/javascripts/behaviors/shortcuts/shortcuts_issuable_spec.js index 01b5bc112b2..bc25549cbed 100644 --- a/spec/javascripts/behaviors/shortcuts/shortcuts_issuable_spec.js +++ b/spec/javascripts/behaviors/shortcuts/shortcuts_issuable_spec.js @@ -57,9 +57,11 @@ describe('ShortcutsIssuable', function() { it('leaves existing input intact', () => { $(FORM_SELECTOR).val('This text was already here.'); + expect($(FORM_SELECTOR).val()).toBe('This text was already here.'); ShortcutsIssuable.replyWithSelectedText(true); + expect($(FORM_SELECTOR).val()).toBe('This text was already here.\n\n> Selected text.\n\n'); }); @@ -70,6 +72,7 @@ describe('ShortcutsIssuable', function() { }); ShortcutsIssuable.replyWithSelectedText(true); + expect(triggered).toBe(true); }); |