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
|
import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { s__ } from '~/locale';
import RunnerAwsDeploymentsModal from '~/vue_shared/components/runner_aws_deployments/runner_aws_deployments_modal.vue';
import RunnerAwsInstructions from '~/vue_shared/components/runner_instructions/instructions/runner_aws_instructions.vue';
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
visitUrl: jest.fn(),
}));
const mockModalId = 'runner-aws-deployments-modal';
describe('RunnerAwsDeploymentsModal', () => {
let wrapper;
const findModal = () => wrapper.findComponent(GlModal);
const findRunnerAwsInstructions = () => wrapper.findComponent(RunnerAwsInstructions);
const createComponent = (options) => {
wrapper = shallowMount(RunnerAwsDeploymentsModal, {
propsData: {
modalId: mockModalId,
},
...options,
});
};
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders modal', () => {
expect(findModal().props()).toMatchObject({
size: 'sm',
modalId: mockModalId,
title: s__('Runners|Deploy GitLab Runner in AWS'),
});
expect(findModal().attributes()).toMatchObject({
'hide-footer': '',
});
});
it('renders modal contents', () => {
expect(findRunnerAwsInstructions().exists()).toBe(true);
});
it('when contents trigger closing, modal closes', () => {
const mockClose = jest.fn();
createComponent({
stubs: {
GlModal: {
template: '<div><slot/></div>',
methods: {
close: mockClose,
},
},
},
});
expect(mockClose).toHaveBeenCalledTimes(0);
findRunnerAwsInstructions().vm.$emit('close');
expect(mockClose).toHaveBeenCalledTimes(1);
});
});
|