Commit 96efba34 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'winh-jest-markdown-header' into 'master'

Migrate markdown header_spec.js to Jest

See merge request gitlab-org/gitlab-ce!30228
parents d427c05f f5461d7b
---
title: Migrate markdown header_spec.js to Jest
merge_request: 30228
author: Martin Hobert
type: other
...@@ -53,7 +53,7 @@ describe('Markdown field header component', () => { ...@@ -53,7 +53,7 @@ describe('Markdown field header component', () => {
}); });
it('emits toggle markdown event when clicking preview', () => { it('emits toggle markdown event when clicking preview', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit').mockImplementation();
vm.$el.querySelector('.js-preview-link').click(); vm.$el.querySelector('.js-preview-link').click();
...@@ -65,7 +65,7 @@ describe('Markdown field header component', () => { ...@@ -65,7 +65,7 @@ describe('Markdown field header component', () => {
}); });
it('does not emit toggle markdown event when triggered from another form', () => { it('does not emit toggle markdown event when triggered from another form', () => {
spyOn(vm, '$emit'); jest.spyOn(vm, '$emit').mockImplementation();
$(document).triggerHandler('markdown-preview:show', [ $(document).triggerHandler('markdown-preview:show', [
$( $(
...@@ -76,17 +76,13 @@ describe('Markdown field header component', () => { ...@@ -76,17 +76,13 @@ describe('Markdown field header component', () => {
expect(vm.$emit).not.toHaveBeenCalled(); expect(vm.$emit).not.toHaveBeenCalled();
}); });
it('blurs preview link after click', done => { it('blurs preview link after click', () => {
const link = vm.$el.querySelector('li:nth-child(2) button'); const link = vm.$el.querySelector('li:nth-child(2) button');
spyOn(HTMLElement.prototype, 'blur'); jest.spyOn(HTMLElement.prototype, 'blur').mockImplementation();
link.click(); link.click();
setTimeout(() => { expect(link.blur).toHaveBeenCalled();
expect(link.blur).toHaveBeenCalled();
done();
});
}); });
it('renders markdown table template', () => { it('renders markdown table template', () => {
......
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