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

ui.js « @gitlab « __mocks__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 04b3215a88a7df9ec12349554f1dcf5e3971082a (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import '~/commons/gitlab_ui';

export * from '@gitlab/ui';

/**
 * The @gitlab/ui tooltip directive requires awkward and distracting set up in tests
 * for components that use it (e.g., `attachTo: document.body` and `sync: true` passed
 * to the `mount` helper from `vue-test-utils`).
 *
 * This mock decouples those tests from the implementation, removing the need to set
 * them up specially just for these tooltips.
 *
 * Mocking the modules using the full file path allows the mocks to take effect
 * when the modules are imported in this project (`gitlab`) **and** when they
 * are imported internally in `@gitlab/ui`.
 */

/* eslint-disable global-require */

jest.mock('@gitlab/ui/src/directives/tooltip.js', () => ({
  GlTooltipDirective: {
    bind() {},
  },
}));
jest.mock('@gitlab/ui/dist/directives/tooltip.js', () =>
  require('@gitlab/ui/src/directives/tooltip'),
);

jest.mock('@gitlab/ui/src/components/base/tooltip/tooltip.vue', () => ({
  props: ['target', 'id', 'triggers', 'placement', 'container', 'boundary', 'disabled', 'show'],
  render(h) {
    return h(
      'div',
      {
        class: 'gl-tooltip',
        ...this.$attrs,
      },
      this.$slots.default,
    );
  },
}));

jest.mock('@gitlab/ui/dist/components/base/tooltip/tooltip.js', () =>
  require('@gitlab/ui/src/components/base/tooltip/tooltip.vue'),
);

jest.mock('@gitlab/ui/src/components/base/popover/popover.vue', () => ({
  props: {
    cssClasses: {
      type: Array,
      required: false,
      default: () => [],
    },
    ...Object.fromEntries(
      [
        'title',
        'target',
        'triggers',
        'placement',
        'boundary',
        'container',
        'showCloseButton',
        'show',
        'boundaryPadding',
      ].map((prop) => [prop, {}]),
    ),
  },
  render(h) {
    return h(
      'div',
      {
        class: 'gl-popover',
        ...this.$attrs,
      },
      Object.keys(this.$slots).map((s) => this.$slots[s]),
    );
  },
}));
jest.mock('@gitlab/ui/dist/components/base/popover/popover.js', () =>
  require('@gitlab/ui/src/components/base/popover/popover.vue'),
);