diff options
author | Rajat Jain <rjain@gitlab.com> | 2019-04-16 11:20:37 +0300 |
---|---|---|
committer | Kushal Pandya <kushalspandya@gmail.com> | 2019-04-16 11:20:37 +0300 |
commit | c23c141e872d3a8a2f32f3fd6ed7901eaef88465 (patch) | |
tree | e712f858aaf35f4a0fa694bb8aec792420b76faf /spec/javascripts/issue_show | |
parent | 224916f843d3cc7beff383217d199a8cabfec263 (diff) |
Autosave description in epics
When editing an epic, the progress was previously lost due to
lack of localstorage syncing code. This commit adds support for
localstorage sync.
Diffstat (limited to 'spec/javascripts/issue_show')
4 files changed, 80 insertions, 0 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index dfc889773c1..2770743937e 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -470,4 +470,51 @@ describe('Issuable output', () => { .catch(done.fail); }); }); + + describe('issueChanged', () => { + beforeEach(() => { + vm.store.formState.title = ''; + vm.store.formState.description = ''; + vm.initialDescriptionText = ''; + vm.initialTitleText = ''; + }); + + it('returns true when title is changed', () => { + vm.store.formState.title = 'RandomText'; + + expect(vm.issueChanged).toBe(true); + }); + + it('returns false when title is empty null', () => { + vm.store.formState.title = null; + + expect(vm.issueChanged).toBe(false); + }); + + it('returns false when `initialTitleText` is null and `formState.title` is empty string', () => { + vm.store.formState.title = ''; + vm.initialTitleText = null; + + expect(vm.issueChanged).toBe(false); + }); + + it('returns true when description is changed', () => { + vm.store.formState.description = 'RandomText'; + + expect(vm.issueChanged).toBe(true); + }); + + it('returns false when description is empty null', () => { + vm.store.formState.title = null; + + expect(vm.issueChanged).toBe(false); + }); + + it('returns false when `initialDescriptionText` is null and `formState.description` is empty string', () => { + vm.store.formState.description = ''; + vm.initialDescriptionText = null; + + expect(vm.issueChanged).toBe(false); + }); + }); }); diff --git a/spec/javascripts/issue_show/components/fields/description_spec.js b/spec/javascripts/issue_show/components/fields/description_spec.js index 2c3efc8d4d4..f5f87a6bfbf 100644 --- a/spec/javascripts/issue_show/components/fields/description_spec.js +++ b/spec/javascripts/issue_show/components/fields/description_spec.js @@ -63,4 +63,8 @@ describe('Description field component', () => { expect(eventHub.$emit).toHaveBeenCalled(); }); + + it('has a ref named `textarea`', () => { + expect(vm.$refs.textarea).not.toBeNull(); + }); }); diff --git a/spec/javascripts/issue_show/components/fields/title_spec.js b/spec/javascripts/issue_show/components/fields/title_spec.js index 4b96a1feb29..62dff983250 100644 --- a/spec/javascripts/issue_show/components/fields/title_spec.js +++ b/spec/javascripts/issue_show/components/fields/title_spec.js @@ -41,4 +41,8 @@ describe('Title field component', () => { expect(eventHub.$emit).toHaveBeenCalled(); }); + + it('has a ref named `input`', () => { + expect(vm.$refs.input).not.toBeNull(); + }); }); diff --git a/spec/javascripts/issue_show/components/form_spec.js b/spec/javascripts/issue_show/components/form_spec.js index 523954013cf..b0f4ab2b12d 100644 --- a/spec/javascripts/issue_show/components/form_spec.js +++ b/spec/javascripts/issue_show/components/form_spec.js @@ -1,10 +1,17 @@ import Vue from 'vue'; import formComponent from '~/issue_show/components/form.vue'; +import eventHub from '~/issue_show/event_hub'; describe('Inline edit form component', () => { let vm; + let autosave; + let autosaveObj; beforeEach(done => { + autosaveObj = { reset: jasmine.createSpy() }; + + autosave = spyOnDependency(formComponent, 'Autosave').and.returnValue(autosaveObj); + const Component = Vue.extend(formComponent); vm = new Component({ @@ -53,4 +60,22 @@ describe('Inline edit form component', () => { done(); }); }); + + it('initialized Autosave on mount', () => { + expect(autosave).toHaveBeenCalledTimes(2); + }); + + it('calls reset on autosave when eventHub emits appropriate events', () => { + eventHub.$emit('close.form'); + + expect(autosaveObj.reset).toHaveBeenCalledTimes(2); + + eventHub.$emit('delete.issuable'); + + expect(autosaveObj.reset).toHaveBeenCalledTimes(4); + + eventHub.$emit('update.issuable'); + + expect(autosaveObj.reset).toHaveBeenCalledTimes(6); + }); }); |