summaryrefslogtreecommitdiff
path: root/spec/javascripts/monitoring/components/graph_group_spec.js
blob: 068c4b5302c56d1fe99bb1873ae3adc0cb46c4d6 (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 { shallowMount } from '@vue/test-utils';
import GraphGroup from '~/monitoring/components/graph_group.vue';

describe('Graph group component', () => {
  let graphGroup;

  afterEach(() => {
    graphGroup.destroy();
  });

  describe('When groups can be collapsed', () => {
    beforeEach(() => {
      graphGroup = shallowMount(GraphGroup, {
        propsData: {
          name: 'panel',
          collapseGroup: true,
        },
      });
    });

    it('should show the angle-down caret icon when collapseGroup is true', () => {
      expect(graphGroup.vm.caretIcon).toBe('angle-down');
    });

    it('should show the angle-right caret icon when collapseGroup is false', () => {
      graphGroup.vm.collapse();

      expect(graphGroup.vm.caretIcon).toBe('angle-right');
    });
  });

  describe('When groups can not be collapsed', () => {
    beforeEach(() => {
      graphGroup = shallowMount(GraphGroup, {
        propsData: {
          name: 'panel',
          collapseGroup: true,
          showPanels: false,
        },
      });
    });

    it('should not contain a prometheus-graph-group container when showPanels is false', () => {
      expect(graphGroup.vm.$el.querySelector('.prometheus-graph-group')).toBe(null);
    });
  });
});