diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2018-01-17 21:58:42 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2018-01-18 15:18:01 +0300 |
commit | 89c3c88e6d681d3c9297f5ed506a8075a272610d (patch) | |
tree | c59e855a92ddc4a29df4487bcf5925d12eb4bb1a /spec | |
parent | 50a649530a53a04d2044f9e4c5502586a7ed0c59 (diff) |
Add confirm when navigating away from page with tests.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/issue_show/components/app_spec.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index 1454ca52018..9280db072b3 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -218,6 +218,39 @@ describe('Issuable output', () => { }); }); + describe('shows dialog when issue has unsaved changed', () => { + it('confirms on title change', (done) => { + vm.showForm = true; + vm.state.titleText = 'title has changed'; + const e = { returnValue: null }; + vm.handleBeforeUnloadEvent(e); + Vue.nextTick(() => { + expect(e.returnValue).not.toBeNull(); + done(); + }); + }); + + it('confirms on description change', (done) => { + vm.showForm = true; + vm.state.descriptionText = 'description has changed'; + const e = { returnValue: null }; + vm.handleBeforeUnloadEvent(e); + Vue.nextTick(() => { + expect(e.returnValue).not.toBeNull(); + done(); + }); + }); + + it('does nothing when nothing has changed', (done) => { + const e = { returnValue: null }; + vm.handleBeforeUnloadEvent(e); + Vue.nextTick(() => { + expect(e.returnValue).toBeNull(); + done(); + }); + }); + }); + describe('error when updating', () => { beforeEach(() => { spyOn(window, 'Flash').and.callThrough(); |