Commit efd32f82 authored by Kushal Pandya's avatar Kushal Pandya

Add IssuableDescription component

Adds IssuableDescription component to use with
Issuable Show app.
parent ad9886b9
<script>
import $ from 'jquery';
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import '~/behaviors/markdown/render_gfm';
export default {
directives: {
SafeHtml,
},
props: {
issuable: {
type: Object,
required: true,
},
},
mounted() {
this.renderGFM();
},
methods: {
renderGFM() {
$(this.$refs.gfmContainer).renderGFM();
},
},
};
</script>
<template>
<div class="description">
<div ref="gfmContainer" v-safe-html="issuable.descriptionHtml" class="md"></div>
</div>
</template>
import $ from 'jquery';
import { shallowMount } from '@vue/test-utils';
import IssuableDescription from '~/issuable_show/components/issuable_description.vue';
import { mockIssuable } from '../mock_data';
const createComponent = (issuable = mockIssuable) =>
shallowMount(IssuableDescription, {
propsData: { issuable },
});
describe('IssuableDescription', () => {
let renderGFMSpy;
let wrapper;
beforeEach(() => {
renderGFMSpy = jest.spyOn($.fn, 'renderGFM');
wrapper = createComponent();
});
afterEach(() => {
wrapper.destroy();
});
describe('mounted', () => {
it('calls `renderGFM`', () => {
expect(renderGFMSpy).toHaveBeenCalledTimes(1);
});
});
describe('methods', () => {
describe('renderGFM', () => {
it('calls `renderGFM` on container element', () => {
wrapper.vm.renderGFM();
expect(renderGFMSpy).toHaveBeenCalled();
});
});
});
});
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