Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dynamic_content_spec.js « widget « components « vue_merge_request_widget « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b7753a587476bb5657aba89109bb84154e040ede (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants';
import DynamicContent from '~/vue_merge_request_widget/components/widget/dynamic_content.vue';

describe('~/vue_merge_request_widget/components/widget/dynamic_content.vue', () => {
  let wrapper;

  const createComponent = ({ propsData } = {}) => {
    wrapper = shallowMountExtended(DynamicContent, {
      propsData: {
        widgetName: 'MyWidget',
        ...propsData,
      },
      stubs: {
        DynamicContent,
      },
    });
  };

  it('renders given data', () => {
    createComponent({
      propsData: {
        data: {
          id: 'row-id',
          header: ['This is a header', 'This is a subheader'],
          text: 'Main text for the row',
          subtext: 'Optional: Smaller sub-text to be displayed below the main text',
          icon: {
            name: EXTENSION_ICONS.success,
          },
          badge: {
            text: 'Badge is optional. Text to be displayed inside badge',
            variant: 'info',
          },
          link: {
            text: 'Optional link to display after text',
            href: 'https://gitlab.com',
          },
          children: [
            {
              id: 'row-id-2',
              header: 'Child row header',
              text: 'This is recursive. It will be listed in level 3.',
            },
          ],
        },
      },
    });

    expect(wrapper.html()).toMatchSnapshot();
  });
});