summaryrefslogtreecommitdiff
path: root/spec/frontend/wikis_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 21:06:28 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-31 21:06:28 +0000
commit8f210aebe1d740e8ee194f171f1f33a6e1fba313 (patch)
treef43c545801bb96fd0737f18493fb30ab92972627 /spec/frontend/wikis_spec.js
parent996f700997805b3590da8d8afdd19d193989078a (diff)
downloadgitlab-ce-8f210aebe1d740e8ee194f171f1f33a6e1fba313.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/wikis_spec.js')
-rw-r--r--spec/frontend/wikis_spec.js40
1 files changed, 24 insertions, 16 deletions
diff --git a/spec/frontend/wikis_spec.js b/spec/frontend/wikis_spec.js
index a2b68bf866e..b2475488d97 100644
--- a/spec/frontend/wikis_spec.js
+++ b/spec/frontend/wikis_spec.js
@@ -3,27 +3,27 @@ import { setHTMLFixture } from './helpers/fixtures';
describe('Wikis', () => {
describe('setting the commit message when the title changes', () => {
+ const editFormHtmlFixture = args => `<form class="wiki-form ${
+ args.newPage ? 'js-new-wiki-page' : ''
+ }">
+ <input type="text" id="wiki_title" value="My title" />
+ <input type="text" id="wiki_message" />
+ </form>`;
+
let wikis;
let titleInput;
let messageInput;
- const CREATE = true;
- const UPDATE = false;
- const editFormHtmlFixture = newPage =>
- `<form class="wiki-form ${newPage ? 'js-new-wiki-page' : ''}">
- <input type="text" id="wiki_page_title" value="My title" />
- <input type="text" id="wiki_page_message" />
- </form>`;
+ describe('when the wiki page is being created', () => {
+ const formHtmlFixture = editFormHtmlFixture({ newPage: true });
- const init = newPage => {
- setHTMLFixture(editFormHtmlFixture(newPage));
- titleInput = document.getElementById('wiki_page_title');
- messageInput = document.getElementById('wiki_page_message');
- wikis = new Wikis();
- };
+ beforeEach(() => {
+ setHTMLFixture(formHtmlFixture);
- describe('when the wiki page is being created', () => {
- beforeEach(() => init(CREATE));
+ titleInput = document.getElementById('wiki_title');
+ messageInput = document.getElementById('wiki_message');
+ wikis = new Wikis();
+ });
it('binds an event listener to the title input', () => {
wikis.handleWikiTitleChange = jest.fn();
@@ -51,7 +51,15 @@ describe('Wikis', () => {
});
describe('when the wiki page is being updated', () => {
- beforeEach(() => init(UPDATE));
+ const formHtmlFixture = editFormHtmlFixture({ newPage: false });
+
+ beforeEach(() => {
+ setHTMLFixture(formHtmlFixture);
+
+ titleInput = document.getElementById('wiki_title');
+ messageInput = document.getElementById('wiki_message');
+ wikis = new Wikis();
+ });
it('sets the commit message when title changes, prefixing with "Update"', () => {
titleInput.value = 'My title';