Skip to content

Commit

Permalink
test: popper mocks, test runner fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adamberecz committed Oct 18, 2023
1 parent b498954 commit d2a435b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/composables/useDropdown.js
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/__mocks__/@popperjs/core/lib/modifiers/flip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
21 changes: 21 additions & 0 deletions tests/unit/__mocks__/@popperjs/core/lib/popper-lite.js
Original file line number Diff line number Diff line change
@@ -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,
}

0 comments on commit d2a435b

Please sign in to comment.