debian-mirror-gitlab/spec/frontend/design_management/components/delete_button_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils';
2022-04-04 11:22:00 +05:30
import { nextTick } from 'vue';
2020-05-24 23:13:21 +05:30
import BatchDeleteButton from '~/design_management/components/delete_button.vue';
describe('Batch delete button component', () => {
let wrapper;
2022-08-27 11:52:29 +05:30
const findButton = () => wrapper.findComponent(GlButton);
const findModal = () => wrapper.findComponent(GlModal);
2020-05-24 23:13:21 +05:30
2020-11-24 15:15:51 +05:30
function createComponent({ isDeleting = false } = {}, { slots = {} } = {}) {
2020-05-24 23:13:21 +05:30
wrapper = shallowMount(BatchDeleteButton, {
propsData: {
isDeleting,
},
directives: {
GlModalDirective,
},
2020-11-24 15:15:51 +05:30
slots,
2020-05-24 23:13:21 +05:30
});
}
it('renders non-disabled button by default', () => {
createComponent();
expect(findButton().exists()).toBe(true);
2022-11-25 23:54:43 +05:30
expect(findButton().attributes('disabled')).toBeUndefined();
2020-05-24 23:13:21 +05:30
});
it('renders disabled button when design is deleting', () => {
2020-11-24 15:15:51 +05:30
createComponent({ isDeleting: true });
2023-07-09 08:55:56 +05:30
expect(findButton().attributes('disabled')).toBeDefined();
2020-05-24 23:13:21 +05:30
});
2022-04-04 11:22:00 +05:30
it('emits `delete-selected-designs` event on modal ok click', async () => {
2020-05-24 23:13:21 +05:30
createComponent();
findButton().vm.$emit('click');
2022-04-04 11:22:00 +05:30
await nextTick();
findModal().vm.$emit('ok');
await nextTick();
2022-11-25 23:54:43 +05:30
expect(wrapper.emitted('delete-selected-designs')).toHaveLength(1);
2020-05-24 23:13:21 +05:30
});
2020-11-24 15:15:51 +05:30
it('renders slot content', () => {
const testText = 'Archive selected';
createComponent(
{},
{
slots: {
default: testText,
},
},
);
expect(findButton().text()).toBe(testText);
});
2020-05-24 23:13:21 +05:30
});