2020-08-04 08:09:48 -04:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-11-15 16:14:31 -05:00
|
|
|
import { GlSprintf } from '@gitlab/ui';
|
2020-08-04 08:09:48 -04:00
|
|
|
import ProjectDeleteButton from '~/projects/components/project_delete_button.vue';
|
|
|
|
import SharedDeleteButton from '~/projects/components/shared/delete_button.vue';
|
|
|
|
|
|
|
|
jest.mock('lodash/uniqueId', () => () => 'fakeUniqueId');
|
|
|
|
|
|
|
|
describe('Project remove modal', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2022-09-12 11:14:03 -04:00
|
|
|
const findSharedDeleteButton = () => wrapper.findComponent(SharedDeleteButton);
|
2020-08-04 08:09:48 -04:00
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
confirmPhrase: 'foo',
|
|
|
|
formPath: 'some/path',
|
2021-11-15 16:14:31 -05:00
|
|
|
isFork: false,
|
|
|
|
issuesCount: 1,
|
|
|
|
mergeRequestsCount: 2,
|
|
|
|
forksCount: 3,
|
|
|
|
starsCount: 4,
|
2020-08-04 08:09:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const createComponent = (props = {}) => {
|
|
|
|
wrapper = shallowMount(ProjectDeleteButton, {
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
stubs: {
|
2021-11-15 16:14:31 -05:00
|
|
|
GlSprintf,
|
2020-08-04 08:09:48 -04:00
|
|
|
SharedDeleteButton,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('initialized', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('matches the snapshot', () => {
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('passes confirmPhrase and formPath props to the shared delete button', () => {
|
2021-11-15 16:14:31 -05:00
|
|
|
expect(findSharedDeleteButton().props()).toEqual({
|
|
|
|
confirmPhrase: defaultProps.confirmPhrase,
|
2022-02-09 01:15:37 -05:00
|
|
|
forksCount: defaultProps.forksCount,
|
2021-11-15 16:14:31 -05:00
|
|
|
formPath: defaultProps.formPath,
|
2022-02-09 01:15:37 -05:00
|
|
|
isFork: defaultProps.isFork,
|
|
|
|
issuesCount: defaultProps.issuesCount,
|
|
|
|
mergeRequestsCount: defaultProps.mergeRequestsCount,
|
|
|
|
starsCount: defaultProps.starsCount,
|
2021-11-15 16:14:31 -05:00
|
|
|
});
|
2020-08-04 08:09:48 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|