From c7cd9ee97cfe1ca8c997b3aad03eb40f5002b317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lu=C3=ADs?= Date: Tue, 31 Jul 2018 01:51:06 +0100 Subject: Revert "Merge branch '_acet-fix-mr-autosave' into 'master'" This reverts commit 5ba542b1094bd8fd95d48d2ac834fd8605cf8fee, reversing changes made to 32c831ea2b8425c71c790b67fb8f2170f3d9955a. --- spec/javascripts/autosave_spec.js | 10 ++++-- .../diffs/components/diff_line_note_form_spec.js | 41 +++++----------------- .../notes/components/noteable_discussion_spec.js | 9 ++--- 3 files changed, 17 insertions(+), 43 deletions(-) (limited to 'spec/javascripts') diff --git a/spec/javascripts/autosave_spec.js b/spec/javascripts/autosave_spec.js index dcb1c781591..38ae5b7e00c 100644 --- a/spec/javascripts/autosave_spec.js +++ b/spec/javascripts/autosave_spec.js @@ -59,10 +59,12 @@ describe('Autosave', () => { Autosave.prototype.restore.call(autosave); - expect(field.trigger).toHaveBeenCalled(); + expect( + field.trigger, + ).toHaveBeenCalled(); }); - it('triggers native event', done => { + it('triggers native event', (done) => { autosave.field.get(0).addEventListener('change', () => { done(); }); @@ -79,7 +81,9 @@ describe('Autosave', () => { it('does not trigger event', () => { spyOn(field, 'trigger').and.callThrough(); - expect(field.trigger).not.toHaveBeenCalled(); + expect( + field.trigger, + ).not.toHaveBeenCalled(); }); }); }); diff --git a/spec/javascripts/diffs/components/diff_line_note_form_spec.js b/spec/javascripts/diffs/components/diff_line_note_form_spec.js index 6fe5fdaf7f9..4600aaea70b 100644 --- a/spec/javascripts/diffs/components/diff_line_note_form_spec.js +++ b/spec/javascripts/diffs/components/diff_line_note_form_spec.js @@ -3,7 +3,6 @@ import DiffLineNoteForm from '~/diffs/components/diff_line_note_form.vue'; import store from '~/mr_notes/stores'; import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import diffFileMockData from '../mock_data/diff_file'; -import { noteableDataMock } from '../../notes/mock_data'; describe('DiffLineNoteForm', () => { let component; @@ -22,9 +21,10 @@ describe('DiffLineNoteForm', () => { noteTargetLine: diffLines[0], }); - Object.defineProperties(component, { - noteableData: { value: noteableDataMock }, - isLoggedIn: { value: true }, + Object.defineProperty(component, 'isLoggedIn', { + get() { + return true; + }, }); component.$mount(); @@ -32,37 +32,12 @@ describe('DiffLineNoteForm', () => { describe('methods', () => { describe('handleCancelCommentForm', () => { - it('should ask for confirmation when shouldConfirm and isDirty passed as truthy', () => { - spyOn(window, 'confirm').and.returnValue(false); - - component.handleCancelCommentForm(true, true); - expect(window.confirm).toHaveBeenCalled(); - }); - - it('should ask for confirmation when one of the params false', () => { - spyOn(window, 'confirm').and.returnValue(false); - - component.handleCancelCommentForm(true, false); - expect(window.confirm).not.toHaveBeenCalled(); - - component.handleCancelCommentForm(false, true); - expect(window.confirm).not.toHaveBeenCalled(); - }); - - it('should call cancelCommentForm with lineCode', done => { - spyOn(window, 'confirm'); + it('should call cancelCommentForm with lineCode', () => { spyOn(component, 'cancelCommentForm'); - spyOn(component, 'resetAutoSave'); component.handleCancelCommentForm(); - expect(window.confirm).not.toHaveBeenCalled(); - component.$nextTick(() => { - expect(component.cancelCommentForm).toHaveBeenCalledWith({ - lineCode: diffLines[0].lineCode, - }); - expect(component.resetAutoSave).toHaveBeenCalled(); - - done(); + expect(component.cancelCommentForm).toHaveBeenCalledWith({ + lineCode: diffLines[0].lineCode, }); }); }); @@ -91,7 +66,7 @@ describe('DiffLineNoteForm', () => { describe('mounted', () => { it('should init autosave', () => { - const key = 'autosave/Note/Issue/98//DiffNote//1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1'; + const key = 'autosave/Note/issue///DiffNote//1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_1'; expect(component.autosave).toBeDefined(); expect(component.autosave.key).toEqual(key); diff --git a/spec/javascripts/notes/components/noteable_discussion_spec.js b/spec/javascripts/notes/components/noteable_discussion_spec.js index f3f50aed232..7da931fd9cb 100644 --- a/spec/javascripts/notes/components/noteable_discussion_spec.js +++ b/spec/javascripts/notes/components/noteable_discussion_spec.js @@ -46,15 +46,10 @@ describe('noteable_discussion component', () => { it('should toggle reply form', done => { vm.$el.querySelector('.js-vue-discussion-reply').click(); - Vue.nextTick(() => { + expect(vm.$refs.noteForm).not.toBeNull(); expect(vm.isReplying).toEqual(true); - - // There is a watcher for `isReplying` which will init autosave in the next tick - Vue.nextTick(() => { - expect(vm.$refs.noteForm).not.toBeNull(); - done(); - }); + done(); }); }); -- cgit v1.2.3