debian-mirror-gitlab/spec/frontend/integrations/edit/components/sections/trigger_spec.js
2022-07-29 14:03:07 +02:00

38 lines
1.1 KiB
JavaScript

import { shallowMount } from '@vue/test-utils';
import IntegrationSectionTrigger from '~/integrations/edit/components/sections/trigger.vue';
import TriggerField from '~/integrations/edit/components/trigger_field.vue';
import { createStore } from '~/integrations/edit/store';
import { mockIntegrationProps } from '../../mock_data';
describe('IntegrationSectionTrigger', () => {
let wrapper;
const createComponent = () => {
const store = createStore({
customState: { ...mockIntegrationProps },
});
wrapper = shallowMount(IntegrationSectionTrigger, {
store,
});
};
afterEach(() => {
wrapper.destroy();
});
const findAllTriggerFields = () => wrapper.findAllComponents(TriggerField);
describe('template', () => {
it('renders correct number of TriggerField components', () => {
createComponent();
const fields = findAllTriggerFields();
expect(fields.length).toBe(mockIntegrationProps.triggerEvents.length);
fields.wrappers.forEach((field, index) => {
expect(field.props('event')).toBe(mockIntegrationProps.triggerEvents[index]);
});
});
});
});