debian-mirror-gitlab/spec/frontend/diffs/components/diff_comment_cell_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import { shallowMount } from '@vue/test-utils';
import DiffCommentCell from '~/diffs/components/diff_comment_cell.vue';
import DiffDiscussionReply from '~/diffs/components/diff_discussion_reply.vue';
2021-03-11 19:13:27 +05:30
import DiffDiscussions from '~/diffs/components/diff_discussions.vue';
2021-01-29 00:20:46 +05:30
describe('DiffCommentCell', () => {
const createWrapper = (props = {}) => {
const { renderDiscussion, ...otherProps } = props;
const line = {
discussions: [],
renderDiscussion,
};
const diffFileHash = 'abc';
return shallowMount(DiffCommentCell, {
propsData: { line, diffFileHash, ...otherProps },
});
};
it('renders discussions if line has discussions', () => {
const wrapper = createWrapper({ renderDiscussion: true });
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(DiffDiscussions).exists()).toBe(true);
2021-01-29 00:20:46 +05:30
});
it('does not render discussions if line has no discussions', () => {
const wrapper = createWrapper();
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(DiffDiscussions).exists()).toBe(false);
2021-01-29 00:20:46 +05:30
});
it('renders discussion reply if line has no draft', () => {
const wrapper = createWrapper();
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(DiffDiscussionReply).exists()).toBe(true);
2021-01-29 00:20:46 +05:30
});
it('does not render discussion reply if line has draft', () => {
const wrapper = createWrapper({ hasDraft: true });
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(DiffDiscussionReply).exists()).toBe(false);
2021-01-29 00:20:46 +05:30
});
});