2020-10-24 23:57:45 +05:30
|
|
|
import { GlFormInput } from '@gitlab/ui';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Vuex from 'vuex';
|
2020-10-24 23:57:45 +05:30
|
|
|
import TagFieldExisting from '~/releases/components/tag_field_existing.vue';
|
|
|
|
import createStore from '~/releases/stores';
|
|
|
|
import createDetailModule from '~/releases/stores/modules/detail';
|
|
|
|
|
|
|
|
const TEST_TAG_NAME = 'test-tag-name';
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe('releases/components/tag_field_existing', () => {
|
|
|
|
let store;
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const createComponent = (mountFn = shallowMount) => {
|
|
|
|
wrapper = mountFn(TagFieldExisting, {
|
|
|
|
store,
|
2020-11-24 15:15:51 +05:30
|
|
|
localVue,
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const findInput = () => wrapper.find(GlFormInput);
|
|
|
|
const findHelp = () => wrapper.find('[data-testid="tag-name-help"]');
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
store = createStore({
|
|
|
|
modules: {
|
|
|
|
detail: createDetailModule({
|
|
|
|
tagName: TEST_TAG_NAME,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
store.state.detail.release = {
|
|
|
|
tagName: TEST_TAG_NAME,
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('default', () => {
|
|
|
|
it('shows the tag name', () => {
|
|
|
|
createComponent();
|
|
|
|
|
|
|
|
expect(findInput().attributes()).toMatchObject({
|
|
|
|
disabled: '',
|
|
|
|
value: TEST_TAG_NAME,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('shows help', () => {
|
|
|
|
createComponent(mount);
|
|
|
|
|
|
|
|
expect(findHelp().text()).toMatchInterpolatedText(
|
2021-01-29 00:20:46 +05:30
|
|
|
"The tag name can't be changed for an existing release.",
|
2020-10-24 23:57:45 +05:30
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|