summaryrefslogtreecommitdiff
path: root/spec/frontend/monitoring/components/group_empty_state_spec.js
blob: 90bd6f6719698311c0d2cc3ea14d78b08efb1cfd (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
import { shallowMount } from '@vue/test-utils';
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',
    },
  });
}

describe('GroupEmptyState', () => {
  const supportedStates = [
    metricStates.NO_DATA,
    metricStates.TIMEOUT,
    metricStates.CONNECTION_FAILED,
    metricStates.BAD_QUERY,
    metricStates.LOADING,
    metricStates.UNKNOWN_ERROR,
    'FOO STATE', // does not fail with unknown states
  ];

  it.each(supportedStates)('Renders an empty state for %s', selectedState => {
    const wrapper = createComponent({ selectedState });

    expect(wrapper.element).toMatchSnapshot();
    // slot is not rendered by the stub, test it separately
    expect(wrapper.vm.currentState.slottedDescription).toMatchSnapshot();
  });
});