2020-10-24 23:57:45 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import EditForm from '~/sidebar/components/lock/edit_form.vue';
|
|
|
|
import { ISSUABLE_TYPE_ISSUE, ISSUABLE_TYPE_MR } from './constants';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe('Edit Form Dropdown', () => {
|
|
|
|
let wrapper;
|
|
|
|
let issuableType; // Either ISSUABLE_TYPE_ISSUE or ISSUABLE_TYPE_MR
|
|
|
|
let issuableDisplayName;
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const setIssuableType = pageType => {
|
|
|
|
issuableType = pageType;
|
|
|
|
issuableDisplayName = issuableType.replace(/_/g, ' ');
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const findWarningText = () => wrapper.find('[data-testid="warning-text"]');
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const createComponent = ({ props }) => {
|
|
|
|
wrapper = shallowMount(EditForm, {
|
2018-03-17 18:26:18 +05:30
|
|
|
propsData: {
|
|
|
|
isLocked: false,
|
2020-10-24 23:57:45 +05:30
|
|
|
issuableDisplayName,
|
|
|
|
...props,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
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 } });
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it(`the appropriate warning text is rendered`, () => {
|
|
|
|
expect(findWarningText().element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
});
|