Commit b21a1d08 authored by Simon Knox's avatar Simon Knox Committed by Vitaly Slobodin

Resolve "jest-as-if-foss 2/2 failing" [RUN AS-IF-FOSS]

parent a87a3d2c
import { shallowMount } from '@vue/test-utils';
import LockButton from 'ee_component/repository/components/lock_button.vue';
import BlobButtonGroup from '~/repository/components/blob_button_group.vue';
const DEFAULT_PROPS = {
name: 'some name',
path: 'some/path',
canPushCode: true,
replacePath: 'some/replace/path',
deletePath: 'some/delete/path',
emptyRepo: false,
projectPath: 'some/project/path',
isLocked: false,
canLock: true,
};
const DEFAULT_INJECT = {
glFeatures: { fileLocks: true },
targetBranch: 'master',
originalBranch: 'master',
};
describe('EE BlobButtonGroup component', () => {
let wrapper;
const createComponent = (props = {}) => {
wrapper = shallowMount(BlobButtonGroup, {
propsData: {
...DEFAULT_PROPS,
...props,
},
provide: {
...DEFAULT_INJECT,
},
});
};
const findLockButton = () => wrapper.findComponent(LockButton);
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders component', () => {
const { name, path } = DEFAULT_PROPS;
expect(wrapper.props()).toMatchObject({
name,
path,
});
});
it('renders the lock button', () => {
expect(findLockButton().exists()).toBe(true);
expect(findLockButton().props()).toMatchObject({
canLock: true,
isLocked: false,
name: 'some name',
path: 'some/path',
projectPath: 'some/project/path',
});
});
});
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import LockButton from 'ee_component/repository/components/lock_button.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import BlobButtonGroup from '~/repository/components/blob_button_group.vue';
import DeleteBlobModal from '~/repository/components/delete_blob_modal.vue';
......@@ -19,7 +18,6 @@ const DEFAULT_PROPS = {
};
const DEFAULT_INJECT = {
glFeatures: { fileLocks: true },
targetBranch: 'master',
originalBranch: 'master',
};
......@@ -49,7 +47,6 @@ describe('BlobButtonGroup component', () => {
const findDeleteBlobModal = () => wrapper.findComponent(DeleteBlobModal);
const findUploadBlobModal = () => wrapper.findComponent(UploadBlobModal);
const findReplaceButton = () => wrapper.find('[data-testid="replace"]');
const findLockButton = () => wrapper.findComponent(LockButton);
it('renders component', () => {
createComponent();
......@@ -67,18 +64,6 @@ describe('BlobButtonGroup component', () => {
createComponent();
});
it('renders the lock button', () => {
expect(findLockButton().exists()).toBe(true);
expect(findLockButton().props()).toMatchObject({
canLock: true,
isLocked: false,
name: 'some name',
path: 'some/path',
projectPath: 'some/project/path',
});
});
it('renders both the replace and delete button', () => {
expect(wrapper.findAll(GlButton)).toHaveLength(2);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment