Commit f79f4336 authored by Nathan Friend's avatar Nathan Friend

Make mocks apply for internal @gitlab/ui imports

This commit updates the way we mock @gitlab/ui modules to allow the
mocks to take effect regardless of where the import lives - in either
`gitlab` or internally in `@gitlab/ui`.
parent 8c5ecfa0
...@@ -7,22 +7,23 @@ export * from '@gitlab/ui'; ...@@ -7,22 +7,23 @@ export * from '@gitlab/ui';
* *
* This mock decouples those tests from the implementation, removing the need to set * This mock decouples those tests from the implementation, removing the need to set
* them up specially just for these tooltips. * 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`.
*/ */
export const GlTooltipDirective = {
jest.mock('@gitlab/ui/dist/directives/tooltip.js', () => ({
bind() {}, bind() {},
}; }));
export const GlTooltip = { jest.mock('@gitlab/ui/dist/components/base/tooltip/tooltip.js', () => ({
render(h) { render(h) {
return h('div', this.$attrs, this.$slots.default); return h('div', this.$attrs, this.$slots.default);
}, },
}; }));
export const GlPopoverDirective = {
bind() {},
};
export const GlPopover = { jest.mock('@gitlab/ui/dist/components/base/popover/popover.js', () => ({
props: { props: {
cssClasses: { cssClasses: {
type: Array, type: Array,
...@@ -33,4 +34,4 @@ export const GlPopover = { ...@@ -33,4 +34,4 @@ export const GlPopover = {
render(h) { render(h) {
return h('div', this.$attrs, Object.keys(this.$slots).map(s => this.$slots[s])); return h('div', this.$attrs, Object.keys(this.$slots).map(s => this.$slots[s]));
}, },
}; }));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment