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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import { GlSprintf } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ListItem from '~/vue_shared/components/registry/list_item.vue';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
import TagsListRow from '~/packages_and_registries/harbor_registry/components/tags/tags_list_row.vue';
import { defaultConfig, harborTagsList } from '../../mock_data';
describe('Harbor tag list row', () => {
let wrapper;
const findListItem = () => wrapper.find(ListItem);
const findClipboardButton = () => wrapper.find(ClipboardButton);
const findByTestId = (testId) => wrapper.findByTestId(testId);
const $route = {
params: {
project: defaultConfig.harborIntegrationProjectName,
image: 'test-repository',
},
};
const mountComponent = ({ propsData, config = defaultConfig }) => {
wrapper = shallowMountExtended(TagsListRow, {
stubs: {
ListItem,
GlSprintf,
},
propsData,
mocks: {
$route,
},
provide() {
return {
...config,
};
},
});
};
afterEach(() => {
wrapper.destroy();
});
describe('list item', () => {
beforeEach(() => {
mountComponent({
propsData: {
tag: harborTagsList[0],
},
});
});
it('exists', () => {
expect(findListItem().exists()).toBe(true);
});
it('has the correct tag name', () => {
expect(findByTestId('name').text()).toBe(harborTagsList[0].name);
});
describe(' clipboard button', () => {
it('exists', () => {
expect(findClipboardButton().exists()).toBe(true);
});
it('has the correct props', () => {
const pullCommand = `docker pull demo.harbor.com/test-project/test-repository:${harborTagsList[0].name}`;
expect(findClipboardButton().attributes()).toMatchObject({
text: pullCommand,
title: pullCommand,
});
});
});
});
});
|