debian-mirror-gitlab/spec/frontend/sidebar/lock/edit_form_spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

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
2021-03-08 18:12:59 +05:30
const setIssuableType = (pageType) => {
2020-10-24 23:57:45 +05:30
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
});
});