biome format --write
This commit is contained in:
parent
8372348148
commit
9262e803ec
415 changed files with 54076 additions and 17419 deletions
74
test/fixtures/setup_test.js
vendored
74
test/fixtures/setup_test.js
vendored
|
|
@ -4,8 +4,8 @@ import VueVirtualScroller from 'vue-virtual-scroller'
|
|||
import routes from 'src/boot/routes'
|
||||
import makeMockStore from './mock_store'
|
||||
|
||||
export const $t = msg => msg
|
||||
const $i18n = { t: msg => msg }
|
||||
export const $t = (msg) => msg
|
||||
const $i18n = { t: (msg) => msg }
|
||||
|
||||
const applyAfterStore = (store, afterStore) => {
|
||||
afterStore(store)
|
||||
|
|
@ -19,17 +19,20 @@ const getDefaultOpts = ({ afterStore = () => {} } = {}) => ({
|
|||
VueVirtualScroller,
|
||||
createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: routes({ state: {
|
||||
users: {
|
||||
currentUser: {}
|
||||
routes: routes({
|
||||
state: {
|
||||
users: {
|
||||
currentUser: {},
|
||||
},
|
||||
instance: {},
|
||||
},
|
||||
instance: {}
|
||||
}})
|
||||
}),
|
||||
}),
|
||||
(Vue) => { Vue.directive('body-scroll-lock', {}) }
|
||||
(Vue) => {
|
||||
Vue.directive('body-scroll-lock', {})
|
||||
},
|
||||
],
|
||||
components: {
|
||||
},
|
||||
components: {},
|
||||
stubs: {
|
||||
I18nT: true,
|
||||
teleport: true,
|
||||
|
|
@ -38,23 +41,23 @@ const getDefaultOpts = ({ afterStore = () => {} } = {}) => ({
|
|||
},
|
||||
mocks: {
|
||||
$t,
|
||||
$i18n
|
||||
}
|
||||
}
|
||||
$i18n,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// https://github.com/vuejs/vue-test-utils/issues/960
|
||||
const customBehaviors = () => {
|
||||
const filterByText = keyword => {
|
||||
const match = keyword instanceof RegExp
|
||||
? (target) => target && keyword.test(target)
|
||||
: (target) => keyword === target
|
||||
const filterByText = (keyword) => {
|
||||
const match =
|
||||
keyword instanceof RegExp
|
||||
? (target) => target && keyword.test(target)
|
||||
: (target) => keyword === target
|
||||
|
||||
return wrapper => (
|
||||
return (wrapper) =>
|
||||
match(wrapper.text()) ||
|
||||
match(wrapper.attributes('aria-label')) ||
|
||||
match(wrapper.attributes('title'))
|
||||
)
|
||||
match(wrapper.attributes('aria-label')) ||
|
||||
match(wrapper.attributes('title'))
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -64,12 +67,10 @@ const customBehaviors = () => {
|
|||
.at(0)
|
||||
},
|
||||
findByText(searchedElement, text) {
|
||||
return this.findAll(searchedElement)
|
||||
.filter(filterByText(text))
|
||||
.at(0)
|
||||
return this.findAll(searchedElement).filter(filterByText(text)).at(0)
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
config.plugins.VueWrapper.install(customBehaviors)
|
||||
|
||||
|
|
@ -79,12 +80,14 @@ export const mountOpts = (allOpts = {}) => {
|
|||
const mergedOpts = {
|
||||
...opts,
|
||||
global: {
|
||||
...defaultOpts.global
|
||||
}
|
||||
...defaultOpts.global,
|
||||
},
|
||||
}
|
||||
|
||||
if (opts.global) {
|
||||
mergedOpts.global.plugins = mergedOpts.global.plugins.concat(opts.global.plugins || [])
|
||||
mergedOpts.global.plugins = mergedOpts.global.plugins.concat(
|
||||
opts.global.plugins || [],
|
||||
)
|
||||
Object.entries(opts.global).forEach(([k, v]) => {
|
||||
if (k === 'plugins') {
|
||||
return
|
||||
|
|
@ -104,10 +107,11 @@ export const mountOpts = (allOpts = {}) => {
|
|||
}
|
||||
|
||||
// https://stackoverflow.com/questions/78033718/how-can-i-wait-for-an-emitted-event-of-a-mounted-component-in-vue-test-utils
|
||||
export const waitForEvent = (wrapper, event, {
|
||||
timeout = 1000,
|
||||
timesEmitted = 1
|
||||
} = {}) => {
|
||||
export const waitForEvent = (
|
||||
wrapper,
|
||||
event,
|
||||
{ timeout = 1000, timesEmitted = 1 } = {},
|
||||
) => {
|
||||
const tick = 10
|
||||
|
||||
return vi.waitFor(
|
||||
|
|
@ -120,7 +124,7 @@ export const waitForEvent = (wrapper, event, {
|
|||
},
|
||||
{
|
||||
timeout,
|
||||
interval: tick
|
||||
}
|
||||
interval: tick,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue