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

custom_metrics_form_spec.js « components « custom_metrics « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c633583f2cbb4c5566e543f747a91760d543bbc9 (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
import { shallowMount } from '@vue/test-utils';
import CustomMetricsForm from '~/custom_metrics/components/custom_metrics_form.vue';

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

  function mountComponent({
    metricPersisted = false,
    formData = {
      title: '',
      query: '',
      yLabel: '',
      unit: '',
      group: '',
      legend: '',
    },
  }) {
    wrapper = shallowMount(CustomMetricsForm, {
      propsData: {
        customMetricsPath: '',
        editIntegrationPath: '',
        metricPersisted,
        validateQueryPath: '',
        formData,
      },
    });
  }

  describe('Computed', () => {
    it('Form button and title text indicate the custom metric is being edited', () => {
      mountComponent({ metricPersisted: true });

      expect(wrapper.vm.saveButtonText).toBe('Save Changes');
      expect(wrapper.vm.titleText).toBe('Edit metric');
    });

    it('Form button and title text indicate the custom metric is being created', () => {
      mountComponent({ metricPersisted: false });

      expect(wrapper.vm.saveButtonText).toBe('Create metric');
      expect(wrapper.vm.titleText).toBe('New metric');
    });
  });
});