debian-mirror-gitlab/spec/frontend/projects/components/project_delete_button_spec.js
2023-05-27 22:25:52 +05:30

57 lines
1.5 KiB
JavaScript

import { shallowMount } from '@vue/test-utils';
import { GlSprintf } from '@gitlab/ui';
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;
const findSharedDeleteButton = () => wrapper.findComponent(SharedDeleteButton);
const defaultProps = {
confirmPhrase: 'foo',
formPath: 'some/path',
isFork: false,
issuesCount: 1,
mergeRequestsCount: 2,
forksCount: 3,
starsCount: 4,
};
const createComponent = (props = {}) => {
wrapper = shallowMount(ProjectDeleteButton, {
propsData: {
...defaultProps,
...props,
},
stubs: {
GlSprintf,
SharedDeleteButton,
},
});
};
describe('initialized', () => {
beforeEach(() => {
createComponent();
});
it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('passes confirmPhrase and formPath props to the shared delete button', () => {
expect(findSharedDeleteButton().props()).toEqual({
confirmPhrase: defaultProps.confirmPhrase,
forksCount: defaultProps.forksCount,
formPath: defaultProps.formPath,
isFork: defaultProps.isFork,
issuesCount: defaultProps.issuesCount,
mergeRequestsCount: defaultProps.mergeRequestsCount,
starsCount: defaultProps.starsCount,
});
});
});
});