summaryrefslogtreecommitdiff
path: root/spec/frontend/analytics/instance_statistics/components/app_spec.js
blob: b945cc20bd6ffeaa1b2fa5cc7a435bfae10a2825 (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
import { shallowMount } from '@vue/test-utils';
import InstanceCounts from '~/analytics/instance_statistics/components//instance_counts.vue';
import InstanceStatisticsApp from '~/analytics/instance_statistics/components/app.vue';
import InstanceStatisticsCountChart from '~/analytics/instance_statistics/components/instance_statistics_count_chart.vue';
import ProjectsAndGroupsChart from '~/analytics/instance_statistics/components/projects_and_groups_chart.vue';
import UsersChart from '~/analytics/instance_statistics/components/users_chart.vue';

describe('InstanceStatisticsApp', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = shallowMount(InstanceStatisticsApp);
  };

  beforeEach(() => {
    createComponent();
  });

  afterEach(() => {
    wrapper.destroy();
    wrapper = null;
  });

  it('displays the instance counts component', () => {
    expect(wrapper.find(InstanceCounts).exists()).toBe(true);
  });

  ['Pipelines', 'Issues & Merge Requests'].forEach((instance) => {
    it(`displays the ${instance} chart`, () => {
      const chartTitles = wrapper
        .findAll(InstanceStatisticsCountChart)
        .wrappers.map((chartComponent) => chartComponent.props('chartTitle'));

      expect(chartTitles).toContain(instance);
    });
  });

  it('displays the users chart component', () => {
    expect(wrapper.find(UsersChart).exists()).toBe(true);
  });

  it('displays the projects and groups chart component', () => {
    expect(wrapper.find(ProjectsAndGroupsChart).exists()).toBe(true);
  });
});