1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import { GlAvatarsInline } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ItemMilestone from '~/issuable/components/issue_milestone.vue';
import WorkItemLinkChildMetadata from '~/work_items/components/work_item_links/work_item_link_child_metadata.vue';
import { workItemObjectiveMetadataWidgets } from '../../mock_data';
describe('WorkItemLinkChildMetadata', () => {
const { MILESTONE, ASSIGNEES } = workItemObjectiveMetadataWidgets;
const mockMilestone = MILESTONE.milestone;
const mockAssignees = ASSIGNEES.assignees.nodes;
let wrapper;
const createComponent = ({ metadataWidgets = workItemObjectiveMetadataWidgets } = {}) => {
wrapper = shallowMountExtended(WorkItemLinkChildMetadata, {
propsData: {
metadataWidgets,
},
slots: {
default: `<div data-testid="default-slot">Foo</div>`,
},
});
};
beforeEach(() => {
createComponent();
});
it('renders default slot contents', () => {
expect(wrapper.findByTestId('default-slot').text()).toBe('Foo');
});
it('renders item milestone', () => {
const milestoneLink = wrapper.findComponent(ItemMilestone);
expect(milestoneLink.exists()).toBe(true);
expect(milestoneLink.props('milestone')).toEqual(mockMilestone);
});
it('renders avatars for assignees', () => {
const avatars = wrapper.findComponent(GlAvatarsInline);
expect(avatars.exists()).toBe(true);
expect(avatars.props()).toMatchObject({
avatars: mockAssignees,
collapsed: true,
maxVisible: 2,
avatarSize: 24,
badgeTooltipProp: 'name',
badgeSrOnlyText: '',
});
});
});
|