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
76
77
78
79
80
81
82
83
|
import { GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import EmptyState from '~/ci/catalog/components/list/empty_state.vue';
import { COMPONENTS_DOCS_URL } from '~/ci/catalog/constants';
describe('EmptyState', () => {
let wrapper;
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
const findComponentsDocLink = () => wrapper.findComponent(GlLink);
const createComponent = ({ props = {} } = {}) => {
wrapper = shallowMountExtended(EmptyState, {
propsData: {
...props,
},
stubs: {
GlEmptyState,
GlSprintf,
},
});
};
describe('default', () => {
beforeEach(() => {
createComponent();
});
it('renders the default empty state', () => {
const emptyState = findEmptyState();
expect(emptyState.exists()).toBe(true);
expect(emptyState.props().title).toBe('Get started with the CI/CD Catalog');
expect(emptyState.props().description).toBe(
'Create a pipeline component repository and make reusing pipeline configurations faster and easier.',
);
});
});
describe('when there is a search query', () => {
beforeEach(() => {
createComponent({
props: { searchTerm: 'a' },
});
});
it('renders the search description', () => {
expect(findEmptyState().text()).toContain(
'Edit your search and try again. Or learn to create a component repository.',
);
});
it('renders the link to the components documentation', () => {
const docsLink = findComponentsDocLink();
expect(docsLink.exists()).toBe(true);
expect(docsLink.attributes().href).toBe(COMPONENTS_DOCS_URL);
});
describe('and it is less than 3 characters', () => {
beforeEach(() => {
createComponent({
props: { searchTerm: 'a' },
});
});
it('render the too few chars empty state title', () => {
expect(findEmptyState().props().title).toBe('Search must be at least 3 characters');
});
});
describe('and it has more than 3 characters', () => {
beforeEach(() => {
createComponent({
props: { searchTerm: 'my component' },
});
});
it('renders the search empty state title', () => {
expect(findEmptyState().props().title).toBe('No result found');
});
});
});
});
|