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

group_empty_state_spec.js « components « monitoring « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4a550efe23cba5c2f4b5e94822daa9b0cbf31e78 (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
48
49
50
51
import { GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { stubComponent } from 'helpers/stub_component';
import GroupEmptyState from '~/monitoring/components/group_empty_state.vue';
import { metricStates } from '~/monitoring/constants';

function createComponent(props) {
  return shallowMount(GroupEmptyState, {
    propsData: {
      ...props,
      documentationPath: '/path/to/docs',
      settingsPath: '/path/to/settings',
      svgPath: '/path/to/empty-group-illustration.svg',
    },
    stubs: {
      GlEmptyState: stubComponent(GlEmptyState, {
        template: '<div><slot name="description"></slot></div>',
      }),
    },
  });
}

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

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

  describe.each([
    metricStates.NO_DATA,
    metricStates.TIMEOUT,
    metricStates.CONNECTION_FAILED,
    metricStates.BAD_QUERY,
    metricStates.LOADING,
    metricStates.UNKNOWN_ERROR,
    'FOO STATE', // does not fail with unknown states
  ])('given state %s', selectedState => {
    beforeEach(() => {
      wrapper = createComponent({ selectedState });
    });

    it('renders the slotted content', () => {
      expect(wrapper.element).toMatchSnapshot();
    });

    it('passes the expected props to GlEmptyState', () => {
      expect(wrapper.find(GlEmptyState).props()).toMatchSnapshot();
    });
  });
});