debian-mirror-gitlab/spec/frontend/integrations/edit/components/sections/configuration_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-07-23 23:45:48 +05:30
import { shallowMount } from '@vue/test-utils';
import IntegrationSectionCoonfiguration from '~/integrations/edit/components/sections/configuration.vue';
import DynamicField from '~/integrations/edit/components/dynamic_field.vue';
import { createStore } from '~/integrations/edit/store';
import { mockIntegrationProps } from '../../mock_data';
describe('IntegrationSectionCoonfiguration', () => {
let wrapper;
const createComponent = ({ customStateProps = {}, props = {} } = {}) => {
const store = createStore({
customState: { ...mockIntegrationProps, ...customStateProps },
});
wrapper = shallowMount(IntegrationSectionCoonfiguration, {
propsData: { ...props },
store,
});
};
const findAllDynamicFields = () => wrapper.findAllComponents(DynamicField);
describe('template', () => {
describe('DynamicField', () => {
it('renders DynamicField for each field', () => {
const fields = [
{ name: 'username', type: 'text' },
{ name: 'API token', type: 'password' },
];
createComponent({
props: {
fields,
},
});
const dynamicFields = findAllDynamicFields();
expect(dynamicFields).toHaveLength(2);
dynamicFields.wrappers.forEach((field, index) => {
expect(field.props()).toMatchObject(fields[index]);
});
});
it('does not render DynamicField when field is empty', () => {
createComponent();
expect(findAllDynamicFields()).toHaveLength(0);
});
});
});
});