summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters/components/uninstall_application_button_spec.js
blob: 9f9397d4d41fdb0f8c4522db358df519348c4afa (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
import { shallowMount } from '@vue/test-utils';
import UninstallApplicationButton from '~/clusters/components/uninstall_application_button.vue';
import LoadingButton from '~/vue_shared/components/loading_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 | label
    ${INSTALLED}    | ${false} | ${false} | ${'Uninstall'}
    ${UPDATING}     | ${false} | ${true}  | ${'Uninstall'}
    ${UNINSTALLING} | ${true}  | ${true}  | ${'Uninstalling'}
  `('when app status is $status', ({ loading, disabled, status, label }) => {
    it(`renders a loading=${loading}, disabled=${disabled} button with label="${label}"`, () => {
      createComponent({ status });
      expect(wrapper.find(LoadingButton).props()).toMatchObject({ loading, disabled, label });
    });
  });
});