debian-mirror-gitlab/spec/frontend/notebook/cells/output/markdown_spec.js
2023-01-13 15:02:22 +05:30

44 lines
1.2 KiB
JavaScript

import { mount } from '@vue/test-utils';
import MarkdownOutput from '~/notebook/cells/output/markdown.vue';
import Prompt from '~/notebook/cells/prompt.vue';
import Markdown from '~/notebook/cells/markdown.vue';
import { relativeRawPath, markdownCellContent } from '../../mock_data';
describe('markdown output cell', () => {
let wrapper;
const createComponent = ({ count = 0, index = 0 } = {}) => {
wrapper = mount(MarkdownOutput, {
provide: { relativeRawPath },
propsData: {
rawCode: markdownCellContent,
count,
index,
},
});
};
beforeEach(() => {
createComponent();
});
const findPrompt = () => wrapper.findComponent(Prompt);
const findMarkdown = () => wrapper.findComponent(Markdown);
it.each`
index | count | showOutput
${0} | ${1} | ${true}
${1} | ${2} | ${false}
${2} | ${3} | ${false}
`('renders a prompt', ({ index, count, showOutput }) => {
createComponent({ count, index });
expect(findPrompt().props()).toMatchObject({ count, showOutput, type: 'Out' });
});
it('renders a Markdown component', () => {
expect(findMarkdown().props()).toMatchObject({
cell: { source: markdownCellContent },
hidePrompt: true,
});
});
});