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
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import RunnerGroups from '~/ci/runner/components/runner_groups.vue';
import RunnerAssignedItem from '~/ci/runner/components/runner_assigned_item.vue';
import { runnerData, runnerWithGroupData } from '../mock_data';
const mockInstanceRunner = runnerData.data.runner;
const mockGroupRunner = runnerWithGroupData.data.runner;
const mockGroup = mockGroupRunner.groups.nodes[0];
describe('RunnerGroups', () => {
let wrapper;
const findHeading = () => wrapper.find('h3');
const findRunnerAssignedItems = () => wrapper.findAllComponents(RunnerAssignedItem);
const createComponent = ({ runner = mockGroupRunner, mountFn = shallowMountExtended } = {}) => {
wrapper = mountFn(RunnerGroups, {
propsData: {
runner,
},
});
};
it('Shows a heading', () => {
createComponent();
expect(findHeading().text()).toBe('Assigned Group');
});
describe('When there is a group runner', () => {
beforeEach(() => {
createComponent();
});
it('Shows a project', () => {
createComponent();
const item = findRunnerAssignedItems().at(0);
const { webUrl, name, fullName, avatarUrl } = mockGroup;
expect(item.props()).toMatchObject({
href: webUrl,
name,
fullName,
avatarUrl,
});
});
});
describe('When there are no groups', () => {
beforeEach(() => {
createComponent({
runner: mockInstanceRunner,
});
});
it('Shows a "None" label', () => {
expect(wrapper.findByText('None').exists()).toBe(true);
});
});
});
|