BigW Consortium Gitlab

deployment_spec.js 1.42 KB
Newer Older
1
import Vue from 'vue';
2 3
import GraphDeployment from '~/monitoring/components/graph/deployment.vue';
import { deploymentData } from '../mock_data';
4 5

const createComponent = (propsData) => {
6
  const Component = Vue.extend(GraphDeployment);
7 8 9 10 11 12 13 14

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

describe('MonitoringDeployment', () => {
  describe('Methods', () => {
15
    it('should contain a hidden gradient', () => {
16
      const component = createComponent({
17 18
        showDeployInfo: true,
        deploymentData,
19
        graphHeight: 300,
20
        graphWidth: 440,
21 22 23
        graphHeightOffset: 120,
      });

24
      expect(component.$el.querySelector('#shadow-gradient')).not.toBeNull();
25 26 27 28 29
    });

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

      expect(
37
        component.transformDeploymentGroup({ xPos: 16 }),
38 39 40 41 42 43 44
      ).toContain('translate(11, 20)');
    });

    describe('Computed props', () => {
      it('calculatedHeight', () => {
        const component = createComponent({
          showDeployInfo: true,
45
          deploymentData,
46
          graphHeight: 300,
47
          graphWidth: 440,
48 49 50 51 52 53 54 55
          graphHeightOffset: 120,
        });

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