diff --git a/src/composables/useDropdown.js b/src/composables/useDropdown.js index 793c1bc..3e77020 100644 --- a/src/composables/useDropdown.js +++ b/src/composables/useDropdown.js @@ -1,7 +1,7 @@ import { ref, toRefs, getCurrentInstance, computed, onMounted, onBeforeUnmount, nextTick } from 'vue' -import { createPopper } from '@popperjs/core/lib/popper-lite.js' -import preventOverflow from '@popperjs/core/lib/modifiers/preventOverflow.js' -import flip from '@popperjs/core/lib/modifiers/flip.js' +import { createPopper } from '@popperjs/core/lib/popper-lite' +import preventOverflow from '@popperjs/core/lib/modifiers/preventOverflow' +import flip from '@popperjs/core/lib/modifiers/flip' export default function useDropdown (props, context, dep) { @@ -104,6 +104,7 @@ export default function useDropdown (props, context, dep) return } + /* istanbul ignore next: popper mock */ popper.value = createPopper(multiselect.value, dropdown.value, { strategy: hasFixedParent(multiselect.value) ? /* istanbul ignore next: UI feature */ 'fixed' : undefined, placement: openDirection.value, diff --git a/tests/unit/__mocks__/@popperjs/core/lib/modifiers/flip.js b/tests/unit/__mocks__/@popperjs/core/lib/modifiers/flip.js new file mode 100644 index 0000000..56004c9 --- /dev/null +++ b/tests/unit/__mocks__/@popperjs/core/lib/modifiers/flip.js @@ -0,0 +1 @@ +export default {} \ No newline at end of file diff --git a/tests/unit/__mocks__/@popperjs/core/lib/modifiers/preventOverflow.js b/tests/unit/__mocks__/@popperjs/core/lib/modifiers/preventOverflow.js new file mode 100644 index 0000000..56004c9 --- /dev/null +++ b/tests/unit/__mocks__/@popperjs/core/lib/modifiers/preventOverflow.js @@ -0,0 +1 @@ +export default {} \ No newline at end of file diff --git a/tests/unit/__mocks__/@popperjs/core/lib/popper-lite.js b/tests/unit/__mocks__/@popperjs/core/lib/popper-lite.js new file mode 100644 index 0000000..0b61db4 --- /dev/null +++ b/tests/unit/__mocks__/@popperjs/core/lib/popper-lite.js @@ -0,0 +1,21 @@ +const createPopper = function (ref, el, options) { + const popper = { + setOptions: (cb) => { + let newOps = cb(options) + + popper.state.placement = newOps.placement + }, + update: () => {}, + destroy: () => {}, + state: { + placement: options.placement + }, + options, + } + + return popper +} + +export { + createPopper, +} \ No newline at end of file