summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters/components/uninstall_application_button_spec.js
blob: 2596820e5acf06980e37322b0b114109da20e719 (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
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import UninstallApplicationButton from '~/clusters/components/uninstall_application_button.vue';
import { APPLICATION_STATUS } from '~/clusters/constants';

const { INSTALLED, UPDATING, UNINSTALLING } = APPLICATION_STATUS;

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

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

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

  describe.each`
    status          | loading  | disabled | text
    ${INSTALLED}    | ${false} | ${false} | ${'Uninstall'}
    ${UPDATING}     | ${false} | ${true}  | ${'Uninstall'}
    ${UNINSTALLING} | ${true}  | ${true}  | ${'Uninstalling'}
  `('when app status is $status', ({ loading, disabled, status, text }) => {
    beforeEach(() => {
      createComponent({ status });
    });

    it(`renders a button with loading=${loading} and disabled=${disabled}`, () => {
      expect(wrapper.find(GlButton).props()).toMatchObject({ loading, disabled });
    });

    it(`renders a button with text="${text}"`, () => {
      expect(wrapper.find(GlButton).text()).toBe(text);
    });
  });
});