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
|
import { mountExtended } from 'helpers/vue_test_utils_helper';
import DeploymentStatusLink from '~/environments/environment_details/components/deployment_status_link.vue';
import DeploymentStatusBadge from '~/environments/components/deployment_status_badge.vue';
describe('app/assets/javascripts/environments/environment_details/components/deployment_status_link.vue', () => {
const testData = {
webPath: 'http://example.com',
status: 'success',
};
let wrapper;
const createWrapper = (props) => {
return mountExtended(DeploymentStatusLink, {
propsData: props,
});
};
describe('when the job link exists', () => {
beforeEach(() => {
wrapper = createWrapper({
deploymentJob: { webPath: testData.webPath },
status: testData.status,
});
});
it('should render a link with a correct href', () => {
const jobLink = wrapper.findByTestId('deployment-status-job-link');
expect(jobLink.exists()).toBe(true);
expect(jobLink.attributes().href).toBe(testData.webPath);
});
it('should render a status badge', () => {
const statusBadge = wrapper.findComponent(DeploymentStatusBadge);
expect(statusBadge.exists()).toBe(true);
expect(statusBadge.props().status).toBe(testData.status);
});
});
describe('when no deployment job is provided', () => {
beforeEach(() => {
wrapper = createWrapper({
status: testData.status,
});
});
it('should render a link with a correct href', () => {
const jobLink = wrapper.findByTestId('deployment-status-job-link');
expect(jobLink.exists()).toBe(false);
});
it('should render only a status badge', () => {
const statusBadge = wrapper.findComponent(DeploymentStatusBadge);
expect(statusBadge.exists()).toBe(true);
expect(statusBadge.props().status).toBe(testData.status);
});
});
});
|