Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import Vue, {ComponentOptions} from 'vue'
import {ThisTypedMountOptions, VueClass} from '@vue/test-utils'
import {Store, StoreOptions} from 'vuex'
import Router, {RouteConfig} from 'vue-router'
// eslint-disable-next-line import/no-extraneous-dependencies
import {
queries,
Expand Down Expand Up @@ -36,12 +34,19 @@ export interface RenderResult extends BoundFunctions<typeof queries> {
updateProps(props: object): Promise<void>
}

export interface RenderOptions<V extends Vue, S = {}>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Store = any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Routes = any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Router = any

export interface RenderOptions<V extends Vue>
// The props and store options special-cased by Vue Testing Library and NOT passed to mount().
extends Omit<ThisTypedMountOptions<V>, 'store' | 'props'> {
props?: object
store?: StoreOptions<S>
routes?: RouteConfig[] | Router
store?: Store
routes?: Routes
container?: Element
baseElement?: Element
}
Expand All @@ -50,11 +55,11 @@ export type ConfigurationCallback<V extends Vue> =
| ((
localVue: typeof Vue,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
store: Store<any>,
store: Store,
router: Router,
) => Partial<ThisTypedMountOptions<V>>)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ((localVue: typeof Vue, store: Store<any>, router: Router) => void)
| ((localVue: typeof Vue, store: Store, router: Router) => void)

export function render<V extends Vue>(
TestComponent: VueClass<V> | ComponentOptions<V>,
Expand Down
9 changes: 1 addition & 8 deletions types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ export function testOptions() {
foos: [4, 5],
bars: ['a', 'b'],
},
getters: {
fooCount() {
return this.foos.length
},
},
},
routes: [
{path: '/', name: 'home', component: SomeComponent},
Expand All @@ -129,10 +124,8 @@ export function testOptions() {

export function testConfigCallback() {
const ExamplePlugin: Vue.PluginFunction<never> = () => {}
render(SomeComponent, {}, (localVue, store, router) => {
render(SomeComponent, {}, localVue => {
localVue.use(ExamplePlugin)
store.replaceState({foo: 'bar'})
router.onError(error => console.log(error.message))
})
}

Expand Down