2020-08-25 20:10:31 -04:00
|
|
|
import { GlButton } from '@gitlab/ui';
|
2021-02-14 13:09:20 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2019-05-02 10:17:03 -04:00
|
|
|
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`
|
2020-08-25 20:10:31 -04:00
|
|
|
status | loading | disabled | text
|
2019-05-02 10:17:03 -04:00
|
|
|
${INSTALLED} | ${false} | ${false} | ${'Uninstall'}
|
|
|
|
${UPDATING} | ${false} | ${true} | ${'Uninstall'}
|
|
|
|
${UNINSTALLING} | ${true} | ${true} | ${'Uninstalling'}
|
2020-08-25 20:10:31 -04:00
|
|
|
`('when app status is $status', ({ loading, disabled, status, text }) => {
|
2020-12-21 10:10:05 -05:00
|
|
|
beforeEach(() => {
|
2019-05-02 10:17:03 -04:00
|
|
|
createComponent({ status });
|
2020-08-25 20:10:31 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
2019-05-02 10:17:03 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|