summaryrefslogtreecommitdiff
path: root/spec/frontend/environments/environment_details/components/deployment_actions_spec.js
blob: 725c8c6479e06be85a2aacc232768db90af2a5c8 (plain)
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
import DeploymentActions from '~/environments/environment_details/components/deployment_actions.vue';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import ActionsComponent from '~/environments/components/environment_actions.vue';

describe('~/environments/environment_details/components/deployment_actions.vue', () => {
  let wrapper;

  const actionsData = [
    {
      playable: true,
      playPath: 'http://www.example.com/play',
      name: 'deploy-staging',
      scheduledAt: '2023-01-18T08:50:08.390Z',
    },
  ];

  const createWrapper = ({ actions }) => {
    return mountExtended(DeploymentActions, {
      propsData: {
        actions,
      },
    });
  };

  describe('when there is no actions provided', () => {
    beforeEach(() => {
      wrapper = createWrapper({ actions: [] });
    });

    it('should not render actions component', () => {
      const actionsComponent = wrapper.findComponent(ActionsComponent);
      expect(actionsComponent.exists()).toBe(false);
    });
  });

  describe('when there are actions provided', () => {
    beforeEach(() => {
      wrapper = createWrapper({ actions: actionsData });
    });

    it('should render actions component', () => {
      const actionsComponent = wrapper.findComponent(ActionsComponent);
      expect(actionsComponent.exists()).toBe(true);
      expect(actionsComponent.props().actions).toBe(actionsData);
    });
  });
});