summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters_list/components/ancestor_notice_spec.js
blob: c931912eaf9d1a046a80d509799b329d761ffaf1 (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 AncestorNotice from '~/clusters_list/components/ancestor_notice.vue';
import ClusterStore from '~/clusters_list/store';
import { shallowMount } from '@vue/test-utils';
import { GlLink, GlSprintf } from '@gitlab/ui';

describe('ClustersAncestorNotice', () => {
  let store;
  let wrapper;

  const createWrapper = () => {
    store = ClusterStore({ ancestorHelperPath: '/some/ancestor/path' });
    wrapper = shallowMount(AncestorNotice, { store, stubs: { GlSprintf } });
    return wrapper.vm.$nextTick();
  };

  beforeEach(() => {
    return createWrapper();
  });

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

  describe('when cluster does not have ancestors', () => {
    beforeEach(() => {
      store.state.hasAncestorClusters = false;
      return wrapper.vm.$nextTick();
    });

    it('displays no notice', () => {
      expect(wrapper.isEmpty()).toBe(true);
    });
  });

  describe('when cluster has ancestors', () => {
    beforeEach(() => {
      store.state.hasAncestorClusters = true;
      return wrapper.vm.$nextTick();
    });

    it('displays notice text', () => {
      expect(wrapper.text()).toContain(
        'Clusters are utilized by selecting the nearest ancestor with a matching environment scope. For example, project clusters will override group clusters.',
      );
    });

    it('displays link', () => {
      expect(wrapper.contains(GlLink)).toBe(true);
    });
  });
});