Commit b2434666 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

FE review, replace timeout with nexttick and improve assertion helper. add changelog

parent 03445de8
---
title: Fix markdown form tabs toggling preview mode from double clicking write mode
button
merge_request: 15119
author:
type: fixed
import Vue from 'vue';
import fieldComponent from '~/vue_shared/components/markdown/field.vue';
import setTimeoutPromise from '../../../helpers/set_timeout_promise_helper';
function assertMarkdownTabs(isWrite, writeLink, previewLink, vm) {
expect(writeLink.parentNode.classList.contains('active')).toEqual(isWrite);
expect(previewLink.parentNode.classList.contains('active')).toEqual(!isWrite);
expect(vm.$el.querySelector('.md-preview').style.display).toEqual(isWrite ? 'none' : '');
}
describe('Markdown field component', () => {
let vm;
......@@ -107,26 +112,19 @@ describe('Markdown field component', () => {
}, 0);
});
function assertLinks(isWrite) {
expect(writeLink.parentNode.classList.contains('active')).toEqual(isWrite);
expect(previewLink.parentNode.classList.contains('active')).toEqual(!isWrite);
expect(vm.$el.querySelector('.md-preview').style.display).toEqual(isWrite ? 'none' : '');
}
it('clicking already active write or preview link does nothing', (done) => {
writeLink.click();
setTimeoutPromise()
.then(() => assertLinks(true))
Vue.nextTick()
.then(() => assertMarkdownTabs(true, writeLink, previewLink, vm))
.then(() => writeLink.click())
.then(() => setTimeoutPromise())
.then(() => assertLinks(true))
.then(() => Vue.nextTick())
.then(() => assertMarkdownTabs(true, writeLink, previewLink, vm))
.then(() => previewLink.click())
.then(() => setTimeoutPromise())
.then(() => assertLinks(false))
.then(() => Vue.nextTick())
.then(() => assertMarkdownTabs(false, writeLink, previewLink, vm))
.then(() => previewLink.click())
.then(() => setTimeoutPromise())
.then(() => assertLinks(false))
.then(() => Vue.nextTick())
.then(() => assertMarkdownTabs(false, writeLink, previewLink, vm))
.then(done)
.catch(done.fail);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment