summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters_list/components/clusters_empty_state_spec.js
blob: 2c3a224f3c81ff6ad1e6df2e100fbc2b5fa603e9 (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
import { GlEmptyState } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ClustersEmptyState from '~/clusters_list/components/clusters_empty_state.vue';

const clustersEmptyStateImage = 'path/to/svg';
const emptyStateHelpText = 'empty state text';

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

  const defaultProvideData = {
    clustersEmptyStateImage,
  };

  const findEmptyStateText = () => wrapper.findByTestId('clusters-empty-state-text');

  const createWrapper = ({ provideData = { emptyStateHelpText: null } } = {}) => {
    wrapper = shallowMountExtended(ClustersEmptyState, {
      provide: { ...defaultProvideData, ...provideData },
      stubs: { GlEmptyState },
    });
  };

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

  describe('when the help text is not provided', () => {
    beforeEach(() => {
      createWrapper();
    });

    it('should not render the empty state text', () => {
      expect(findEmptyStateText().exists()).toBe(false);
    });
  });

  describe('when the help text is provided', () => {
    beforeEach(() => {
      createWrapper({ provideData: { emptyStateHelpText } });
    });

    it('should show the empty state text', () => {
      expect(findEmptyStateText().text()).toBe(emptyStateHelpText);
    });
  });
});