summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters/components/uninstall_application_confirmation_modal_spec.js
blob: 6a7126b45cd4009b551514eb671655fd2acb7aba (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 { shallowMount } from '@vue/test-utils';
import UninstallApplicationConfirmationModal from '~/clusters/components/uninstall_application_confirmation_modal.vue';
import { GlModal } from '@gitlab/ui';
import { INGRESS } from '~/clusters/constants';

describe('UninstallApplicationConfirmationModal', () => {
  let wrapper;
  const appTitle = 'Ingress';

  const createComponent = (props = {}) => {
    wrapper = shallowMount(UninstallApplicationConfirmationModal, {
      propsData: { ...props },
    });
  };

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

  beforeEach(() => {
    createComponent({ application: INGRESS, applicationTitle: appTitle });
  });

  it(`renders a modal with a title "Uninstall ${appTitle}"`, () => {
    expect(wrapper.find(GlModal).attributes('title')).toEqual(`Uninstall ${appTitle}`);
  });

  it(`renders a modal with an ok button labeled "Uninstall ${appTitle}"`, () => {
    expect(wrapper.find(GlModal).attributes('ok-title')).toEqual(`Uninstall ${appTitle}`);
  });

  it('triggers confirm event when ok button is clicked', () => {
    wrapper.find(GlModal).vm.$emit('ok');

    expect(wrapper.emitted('confirm')).toBeTruthy();
  });

  it('displays a warning text indicating the app will be uninstalled', () => {
    expect(wrapper.text()).toContain(`You are about to uninstall ${appTitle} from your cluster.`);
  });

  it('displays a custom warning text depending on the application', () => {
    expect(wrapper.text()).toContain(
      `The associated load balancer and IP will be deleted and cannot be restored.`,
    );
  });
});