summaryrefslogtreecommitdiff
path: root/spec/javascripts/monitoring/graph/deployment_spec.js
blob: d07db871d694f0ef66a4b01bdbff0c639c13189c (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
48
49
50
51
52
53
54
55
import Vue from 'vue';
import GraphDeployment from '~/monitoring/components/graph/deployment.vue';
import { deploymentData } from '../mock_data';

const createComponent = (propsData) => {
  const Component = Vue.extend(GraphDeployment);

  return new Component({
    propsData,
  }).$mount();
};

describe('MonitoringDeployment', () => {
  describe('Methods', () => {
    it('should contain a hidden gradient', () => {
      const component = createComponent({
        showDeployInfo: true,
        deploymentData,
        graphHeight: 300,
        graphWidth: 440,
        graphHeightOffset: 120,
      });

      expect(component.$el.querySelector('#shadow-gradient')).not.toBeNull();
    });

    it('transformDeploymentGroup translates an available deployment', () => {
      const component = createComponent({
        showDeployInfo: false,
        deploymentData,
        graphHeight: 300,
        graphWidth: 440,
        graphHeightOffset: 120,
      });

      expect(
        component.transformDeploymentGroup({ xPos: 16 }),
      ).toContain('translate(11, 20)');
    });

    describe('Computed props', () => {
      it('calculatedHeight', () => {
        const component = createComponent({
          showDeployInfo: true,
          deploymentData,
          graphHeight: 300,
          graphWidth: 440,
          graphHeightOffset: 120,
        });

        expect(component.calculatedHeight).toEqual(180);
      });
    });
  });
});