gitlab-org--gitlab-foss/spec/frontend/sidebar/lock/edit_form_spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

import { shallowMount } from '@vue/test-utils';
import EditForm from '~/sidebar/components/lock/edit_form.vue';
import { ISSUABLE_TYPE_ISSUE, ISSUABLE_TYPE_MR } from './constants';
2017-09-14 07:01:07 -04:00
describe('Edit Form Dropdown', () => {
let wrapper;
let issuableType; // Either ISSUABLE_TYPE_ISSUE or ISSUABLE_TYPE_MR
let issuableDisplayName;
2017-09-14 07:01:07 -04:00
const setIssuableType = (pageType) => {
issuableType = pageType;
issuableDisplayName = issuableType.replace(/_/g, ' ');
};
2017-09-14 07:01:07 -04:00
const findWarningText = () => wrapper.find('[data-testid="warning-text"]');
2017-09-14 07:01:07 -04:00
const createComponent = ({ props }) => {
wrapper = shallowMount(EditForm, {
2017-09-14 07:01:07 -04:00
propsData: {
isLocked: false,
issuableDisplayName,
...props,
2017-09-14 07:01:07 -04:00
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
2017-09-14 07:01:07 -04:00
});
describe.each`
pageType
${ISSUABLE_TYPE_ISSUE} | ${ISSUABLE_TYPE_MR}
`('In $pageType page', ({ pageType }) => {
beforeEach(() => {
setIssuableType(pageType);
});
describe.each`
isLocked | lockStatusText
${false} | ${'unlocked'}
${true} | ${'locked'}
`('when $lockStatusText', ({ isLocked }) => {
beforeEach(() => {
createComponent({ props: { isLocked } });
});
2017-09-14 07:01:07 -04:00
it(`the appropriate warning text is rendered`, () => {
expect(findWarningText().element).toMatchSnapshot();
});
});
2017-09-14 07:01:07 -04:00
});
});