summaryrefslogtreecommitdiff
path: root/spec/frontend/integrations/edit/components/sections/trigger_spec.js
blob: 883f5c7bf79444871d13706c0a81ae7849aad4d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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]);
      });
    });
  });
});