Welcome to mirror list, hosted at ThFree Co, Russian Federation.

activity_chart_spec.js « components « analytics « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c26407f5c1db9fc450bb3b185f9960877dc872d7 (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
import { GlColumnChart } from '@gitlab/ui/dist/charts';
import { shallowMount } from '@vue/test-utils';
import ActivityChart from '~/analytics/product_analytics/components/activity_chart.vue';

describe('Activity Chart Bundle', () => {
  let wrapper;
  function mountComponent({ provide }) {
    wrapper = shallowMount(ActivityChart, {
      provide: {
        formattedData: {},
        ...provide,
      },
    });
  }

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

  const findChart = () => wrapper.findComponent(GlColumnChart);
  const findNoData = () => wrapper.find('[data-testid="noActivityChartData"]');

  describe('Activity Chart', () => {
    it('renders an warning message with no data', () => {
      mountComponent({ provide: { formattedData: {} } });
      expect(findNoData().exists()).toBe(true);
    });

    it('renders a chart with data', () => {
      mountComponent({
        provide: { formattedData: { keys: ['key1', 'key2'], values: [5038, 2241] } },
      });

      expect(findNoData().exists()).toBe(false);
      expect(findChart().exists()).toBe(true);
    });
  });
});