diff options
Diffstat (limited to 'spec/javascripts/issue_show/components/description_spec.js')
-rw-r--r-- | spec/javascripts/issue_show/components/description_spec.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/javascripts/issue_show/components/description_spec.js b/spec/javascripts/issue_show/components/description_spec.js index 463f3c89926..2eeed6770be 100644 --- a/spec/javascripts/issue_show/components/description_spec.js +++ b/spec/javascripts/issue_show/components/description_spec.js @@ -21,7 +21,8 @@ describe('Description component', () => { if (!document.querySelector('.issuable-meta')) { const metaData = document.createElement('div'); metaData.classList.add('issuable-meta'); - metaData.innerHTML = '<span id="task_status"></span><span id="task_status_short"></span>'; + metaData.innerHTML = + '<div class="flash-container"></div><span id="task_status"></span><span id="task_status_short"></span>'; document.body.appendChild(metaData); } @@ -33,6 +34,10 @@ describe('Description component', () => { vm.$destroy(); }); + afterAll(() => { + $('.issuable-meta .flash-container').remove(); + }); + it('animates description changes', done => { vm.descriptionHtml = 'changed'; @@ -123,7 +128,10 @@ describe('Description component', () => { fieldName: 'description', selector: '.detail-page-description', onSuccess: jasmine.any(Function), + onError: jasmine.any(Function), + lockVersion: 0, }); + done(); }); }); @@ -184,4 +192,17 @@ describe('Description component', () => { it('sets data-update-url', () => { expect(vm.$el.querySelector('textarea').dataset.updateUrl).toEqual(gl.TEST_HOST); }); + + describe('taskListUpdateError', () => { + it('should create flash notification and emit an event to parent', () => { + const msg = + 'Someone edited this issue at the same time you did. The description has been updated and you will need to make your changes again.'; + spyOn(vm, '$emit'); + + vm.taskListUpdateError(); + + expect(document.querySelector('.flash-container .flash-text').innerText.trim()).toBe(msg); + expect(vm.$emit).toHaveBeenCalledWith('taskListUpdateFailed'); + }); + }); }); |