diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/frontend/wikis_spec.js | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/frontend/wikis_spec.js')
-rw-r--r-- | spec/frontend/wikis_spec.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/frontend/wikis_spec.js b/spec/frontend/wikis_spec.js index 1d17c8b0777..e5d869840aa 100644 --- a/spec/frontend/wikis_spec.js +++ b/spec/frontend/wikis_spec.js @@ -14,6 +14,7 @@ describe('Wikis', () => { <option value="asciidoc">AsciiDoc</option> <option value="org">Org</option> </select> + <textarea id="wiki_content"></textarea> <code class="js-markup-link-example">{Link title}[link:page-slug]</code> </form> `; @@ -24,6 +25,10 @@ describe('Wikis', () => { let changeFormatSelect; let linkExample; + const findBeforeUnloadWarning = () => window.onbeforeunload?.(); + const findContent = () => document.getElementById('wiki_content'); + const findForm = () => document.querySelector('.wiki-form'); + describe('when the wiki page is being created', () => { const formHtmlFixture = editFormHtmlFixture({ newPage: true }); @@ -94,6 +99,27 @@ describe('Wikis', () => { expect(linkExample.innerHTML).toBe(text); }); + + it('starts with no unload warning', () => { + expect(findBeforeUnloadWarning()).toBeUndefined(); + }); + + describe('when wiki content is updated', () => { + beforeEach(() => { + const content = findContent(); + content.value = 'Lorem ipsum dolar sit!'; + content.dispatchEvent(new Event('input')); + }); + + it('sets before unload warning', () => { + expect(findBeforeUnloadWarning()).toBe(''); + }); + + it('when form submitted, unsets before unload warning', () => { + findForm().dispatchEvent(new Event('submit')); + expect(findBeforeUnloadWarning()).toBeUndefined(); + }); + }); }); }); }); |