debian-mirror-gitlab/spec/frontend/labels/components/delete_label_modal_spec.js

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

56 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
import { GlModal } from '@gitlab/ui';
import { stubComponent } from 'helpers/stub_component';
import { TEST_HOST } from 'helpers/test_constants';
2023-06-20 00:43:36 +05:30
import { mountExtended } from 'helpers/vue_test_utils_helper';
2022-01-26 12:08:38 +05:30
import DeleteLabelModal from '~/labels/components/delete_label_modal.vue';
2021-04-29 21:17:54 +05:30
2022-01-26 12:08:38 +05:30
describe('~/labels/components/delete_label_modal', () => {
2021-04-29 21:17:54 +05:30
let wrapper;
2023-06-20 00:43:36 +05:30
const mountComponent = () => {
const button = document.createElement('button');
button.classList.add('js-test-btn');
button.dataset.destroyPath = `${TEST_HOST}/1`;
button.dataset.labelName = 'label 1';
button.dataset.subjectName = 'GitLab Org';
document.body.append(button);
wrapper = mountExtended(DeleteLabelModal, {
propsData: {
selector: '.js-test-btn',
},
stubs: {
GlModal: stubComponent(GlModal, {
template:
'<div><slot name="modal-title"></slot><slot></slot><slot name="modal-footer"></slot></div>',
}),
},
});
button.click();
2021-04-29 21:17:54 +05:30
};
2022-10-11 01:57:18 +05:30
const findModal = () => wrapper.findComponent(GlModal);
2023-06-20 00:43:36 +05:30
const findDeleteButton = () => wrapper.findByRole('link', { name: 'Delete label' });
describe('when modal data is set', () => {
beforeEach(() => {
mountComponent();
});
it('renders GlModal', () => {
expect(findModal().exists()).toBe(true);
});
it('displays the label name and subject name', () => {
expect(findModal().text()).toContain(
`label 1 will be permanently deleted from GitLab Org. This cannot be undone`,
);
});
it('passes the destroyPath to the button', () => {
expect(findDeleteButton().attributes('href')).toBe('http://test.host/1');
2021-04-29 21:17:54 +05:30
});
});
});