summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters_list/components/agent_empty_state_spec.js
blob: ed2a0d0b97b457991f95a43ab360ba06241e5f04 (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
52
53
54
import { GlEmptyState, GlSprintf, GlLink, GlButton } from '@gitlab/ui';
import AgentEmptyState from '~/clusters_list/components/agent_empty_state.vue';
import { INSTALL_AGENT_MODAL_ID } from '~/clusters_list/constants';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { helpPagePath } from '~/helpers/help_page_helper';

const emptyStateImage = '/path/to/image';
const installDocsUrl = helpPagePath('user/clusters/agent/index');

describe('AgentEmptyStateComponent', () => {
  let wrapper;
  const provideData = {
    emptyStateImage,
  };

  const findInstallDocsLink = () => wrapper.findComponent(GlLink);
  const findIntegrationButton = () => wrapper.findComponent(GlButton);
  const findEmptyState = () => wrapper.findComponent(GlEmptyState);

  beforeEach(() => {
    wrapper = shallowMountExtended(AgentEmptyState, {
      provide: provideData,
      directives: {
        GlModalDirective: createMockDirective(),
      },
      stubs: { GlEmptyState, GlSprintf },
    });
  });

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

  it('renders the empty state', () => {
    expect(findEmptyState().exists()).toBe(true);
  });

  it('renders button for the agent registration', () => {
    expect(findIntegrationButton().exists()).toBe(true);
  });

  it('renders correct href attributes for the docs link', () => {
    expect(findInstallDocsLink().attributes('href')).toBe(installDocsUrl);
  });

  it('renders correct modal id for the agent registration modal', () => {
    const binding = getBinding(findIntegrationButton().element, 'gl-modal-directive');

    expect(binding.value).toBe(INSTALL_AGENT_MODAL_ID);
  });
});