debian-mirror-gitlab/spec/frontend/projects/details/upload_button_spec.js

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

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import UploadButton from '~/projects/details/upload_button.vue';
import UploadBlobModal from '~/repository/components/upload_blob_modal.vue';
const MODAL_ID = 'details-modal-upload-blob';
describe('UploadButton', () => {
let wrapper;
let glModalDirective;
const createComponent = () => {
glModalDirective = jest.fn();
return shallowMount(UploadButton, {
directives: {
glModal: {
bind(_, { value }) {
glModalDirective(value);
},
},
},
});
};
beforeEach(() => {
wrapper = createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('displays an upload button', () => {
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(GlButton).exists()).toBe(true);
2021-04-17 20:07:23 +05:30
});
it('contains a modal', () => {
2022-10-11 01:57:18 +05:30
const modal = wrapper.findComponent(UploadBlobModal);
2021-04-17 20:07:23 +05:30
expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(MODAL_ID);
});
describe('when clickinig the upload file button', () => {
beforeEach(() => {
2022-10-11 01:57:18 +05:30
wrapper.findComponent(GlButton).vm.$emit('click');
2021-04-17 20:07:23 +05:30
});
it('opens the modal', () => {
expect(glModalDirective).toHaveBeenCalledWith(MODAL_ID);
});
});
});