summaryrefslogtreecommitdiff
path: root/spec/frontend/environments/environment_details/components/deployment_status_link_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/environments/environment_details/components/deployment_status_link_spec.js')
-rw-r--r--spec/frontend/environments/environment_details/components/deployment_status_link_spec.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/frontend/environments/environment_details/components/deployment_status_link_spec.js b/spec/frontend/environments/environment_details/components/deployment_status_link_spec.js
new file mode 100644
index 00000000000..5db7740423a
--- /dev/null
+++ b/spec/frontend/environments/environment_details/components/deployment_status_link_spec.js
@@ -0,0 +1,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);
+ });
+ });
+});