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
|
import { shallowMount } from '@vue/test-utils';
import TagsList from '~/packages_and_registries/harbor_registry/components/tags/tags_list.vue';
import TagsLoader from '~/packages_and_registries/shared/components/tags_loader.vue';
import TagsListRow from '~/packages_and_registries/harbor_registry/components/tags/tags_list_row.vue';
import RegistryList from '~/packages_and_registries/shared/components/registry_list.vue';
import { defaultConfig, harborTagsResponse } from '../../mock_data';
describe('Harbor Tags List', () => {
let wrapper;
const findTagsLoader = () => wrapper.findComponent(TagsLoader);
const findTagsListRows = () => wrapper.findAllComponents(TagsListRow);
const findRegistryList = () => wrapper.findComponent(RegistryList);
const mountComponent = ({ propsData, config = defaultConfig }) => {
wrapper = shallowMount(TagsList, {
propsData,
stubs: { RegistryList },
provide() {
return {
...config,
};
},
});
};
afterEach(() => {
wrapper.destroy();
});
describe('when isLoading is true', () => {
beforeEach(() => {
mountComponent({
propsData: {
isLoading: true,
pageInfo: {},
tags: [],
},
});
});
it('show the loader', () => {
expect(findTagsLoader().exists()).toBe(true);
});
});
describe('tags list', () => {
beforeEach(() => {
mountComponent({
propsData: {
isLoading: false,
pageInfo: {},
tags: harborTagsResponse,
},
});
});
it('should render correctly', () => {
expect(findRegistryList().exists()).toBe(true);
});
it('one tag row exists', () => {
expect(findTagsListRows()).toHaveLength(harborTagsResponse.length);
});
});
});
|