Commit af4bb5e9 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'vs-remove-invalid-spec-from-field_spec' into 'master'

Remove invalid test from field_spec

Closes #37249

See merge request gitlab-org/gitlab!30719
parents 305a4e2b e3277651
...@@ -9,9 +9,9 @@ const markdownPreviewPath = `${TEST_HOST}/preview`; ...@@ -9,9 +9,9 @@ const markdownPreviewPath = `${TEST_HOST}/preview`;
const markdownDocsPath = `${TEST_HOST}/docs`; const markdownDocsPath = `${TEST_HOST}/docs`;
function assertMarkdownTabs(isWrite, writeLink, previewLink, wrapper) { function assertMarkdownTabs(isWrite, writeLink, previewLink, wrapper) {
expect(writeLink.element.parentNode.classList.contains('active')).toEqual(isWrite); expect(writeLink.element.parentNode.classList.contains('active')).toBe(isWrite);
expect(previewLink.element.parentNode.classList.contains('active')).toEqual(!isWrite); expect(previewLink.element.parentNode.classList.contains('active')).toBe(!isWrite);
expect(wrapper.find('.md-preview-holder').element.style.display).toEqual(isWrite ? 'none' : ''); expect(wrapper.find('.md-preview-holder').element.style.display).toBe(isWrite ? 'none' : '');
} }
function createComponent() { function createComponent() {
...@@ -67,6 +67,10 @@ describe('Markdown field component', () => { ...@@ -67,6 +67,10 @@ describe('Markdown field component', () => {
let previewLink; let previewLink;
let writeLink; let writeLink;
afterEach(() => {
wrapper.destroy();
});
it('renders textarea inside backdrop', () => { it('renders textarea inside backdrop', () => {
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.find('.zen-backdrop textarea').element).not.toBeNull(); expect(wrapper.find('.zen-backdrop textarea').element).not.toBeNull();
...@@ -92,32 +96,24 @@ describe('Markdown field component', () => { ...@@ -92,32 +96,24 @@ describe('Markdown field component', () => {
previewLink = getPreviewLink(wrapper); previewLink = getPreviewLink(wrapper);
previewLink.trigger('click'); previewLink.trigger('click');
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.find('.md-preview-holder').element.textContent.trim()).toContain( expect(wrapper.find('.md-preview-holder').element.textContent.trim()).toContain(
'Loading…', 'Loading…',
); );
}); });
}); });
it('renders markdown preview', () => { it('renders markdown preview and GFM', () => {
wrapper = createComponent(); wrapper = createComponent();
previewLink = getPreviewLink(wrapper); const renderGFMSpy = jest.spyOn($.fn, 'renderGFM');
previewLink.trigger('click');
setTimeout(() => {
expect(wrapper.find('.md-preview-holder').element.innerHTML).toContain(previewHTML);
});
});
it('renders GFM with jQuery', () => {
wrapper = createComponent();
previewLink = getPreviewLink(wrapper); previewLink = getPreviewLink(wrapper);
jest.spyOn($.fn, 'renderGFM');
previewLink.trigger('click'); previewLink.trigger('click');
return axios.waitFor(markdownPreviewPath).then(() => { return axios.waitFor(markdownPreviewPath).then(() => {
expect(wrapper.find('.md-preview-holder').element.innerHTML).toContain(previewHTML); expect(wrapper.find('.md-preview-holder').element.innerHTML).toContain(previewHTML);
expect(renderGFMSpy).toHaveBeenCalled();
}); });
}); });
...@@ -176,7 +172,7 @@ describe('Markdown field component', () => { ...@@ -176,7 +172,7 @@ describe('Markdown field component', () => {
const markdownButton = getMarkdownButton(wrapper); const markdownButton = getMarkdownButton(wrapper);
markdownButton.trigger('click'); markdownButton.trigger('click');
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(textarea.value).toContain('**testing**'); expect(textarea.value).toContain('**testing**');
}); });
}); });
...@@ -188,7 +184,7 @@ describe('Markdown field component', () => { ...@@ -188,7 +184,7 @@ describe('Markdown field component', () => {
const markdownButton = getAllMarkdownButtons(wrapper).wrappers[5]; const markdownButton = getAllMarkdownButtons(wrapper).wrappers[5];
markdownButton.trigger('click'); markdownButton.trigger('click');
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(textarea.value).toContain('* testing'); expect(textarea.value).toContain('* testing');
}); });
}); });
...@@ -200,7 +196,7 @@ describe('Markdown field component', () => { ...@@ -200,7 +196,7 @@ describe('Markdown field component', () => {
const markdownButton = getAllMarkdownButtons(wrapper).wrappers[5]; const markdownButton = getAllMarkdownButtons(wrapper).wrappers[5];
markdownButton.trigger('click'); markdownButton.trigger('click');
wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(textarea.value).toContain('* testing\n* 123'); expect(textarea.value).toContain('* testing\n* 123');
}); });
}); });
......
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