2020-07-29 11:09:39 -04:00
|
|
|
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
|
|
|
|
2020-07-29 11:09:39 -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
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
const setIssuableType = (pageType) => {
|
2020-07-29 11:09:39 -04:00
|
|
|
issuableType = pageType;
|
|
|
|
issuableDisplayName = issuableType.replace(/_/g, ' ');
|
|
|
|
};
|
2017-09-14 07:01:07 -04:00
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
const findWarningText = () => wrapper.find('[data-testid="warning-text"]');
|
2017-09-14 07:01:07 -04:00
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
const createComponent = ({ props }) => {
|
|
|
|
wrapper = shallowMount(EditForm, {
|
2017-09-14 07:01:07 -04:00
|
|
|
propsData: {
|
|
|
|
isLocked: false,
|
2020-07-29 11:09:39 -04:00
|
|
|
issuableDisplayName,
|
|
|
|
...props,
|
2017-09-14 07:01:07 -04:00
|
|
|
},
|
2020-07-29 11:09:39 -04:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
2017-09-14 07:01:07 -04:00
|
|
|
});
|
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
describe.each`
|
|
|
|
pageType
|
|
|
|
${ISSUABLE_TYPE_ISSUE} | ${ISSUABLE_TYPE_MR}
|
|
|
|
`('In $pageType page', ({ pageType }) => {
|
|
|
|
beforeEach(() => {
|
|
|
|
setIssuableType(pageType);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe.each`
|
2020-08-18 17:09:57 -04:00
|
|
|
isLocked | lockStatusText
|
|
|
|
${false} | ${'unlocked'}
|
|
|
|
${true} | ${'locked'}
|
|
|
|
`('when $lockStatusText', ({ isLocked }) => {
|
2020-07-29 11:09:39 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
createComponent({ props: { isLocked } });
|
|
|
|
});
|
2017-09-14 07:01:07 -04:00
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
it(`the appropriate warning text is rendered`, () => {
|
2020-08-18 17:09:57 -04:00
|
|
|
expect(findWarningText().element).toMatchSnapshot();
|
2020-07-29 11:09:39 -04:00
|
|
|
});
|
|
|
|
});
|
2017-09-14 07:01:07 -04:00
|
|
|
});
|
|
|
|
});
|