Skip to content

feat: export createWrapper and add createWrapperArray functions #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import shallow from './shallow'
import mount from './mount'
import createLocalVue from './create-local-vue'
import createWrapper from './wrappers/create-wrapper'
import createWrapperArray from './wrappers/create-wrapper-array'
import TransitionStub from './components/TransitionStub'
import TransitionGroupStub from './components/TransitionGroupStub'
import config from './config'

export default {
createLocalVue,
createWrapper,
createWrapperArray,
config,
mount,
shallow,
Expand Down
9 changes: 9 additions & 0 deletions src/wrappers/create-wrapper-array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

import WrapperArray from './wrapper-array'
import type Wrapper from './wrapper'
import type VueWrapper from './vue-wrapper'

export default function createWrapperArray (wrappers: Array<Wrapper | VueWrapper>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you write a few tests for this method and add validation (so check that Wrappers is an array of wrappers and throw an error if not)

return new WrapperArray(wrappers)
}
4 changes: 3 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Vue, { VNodeData, ComponentOptions, FunctionalComponentOptions } from 'vue'
import Vue, { VNode, VNodeData, ComponentOptions, FunctionalComponentOptions } from 'vue'

// TODO: use core repo's Component type after https://github.com/vuejs/vue/pull/7369 is released
export type Component =
Expand Down Expand Up @@ -126,6 +126,8 @@ interface VueTestUtilsConfigOptions {
}

export declare function createLocalVue (): typeof Vue
export declare function createWrapper (node: VNode | Component, update?: Function, options?: WrapperOptions): Wrapper<Vue>
export declare function createWrapperArray<T extends Vue> (wrappers: Array<Wrapper<T>>): WrapperArray<T>
export declare let config: VueTestUtilsConfigOptions

export declare function mount<V extends Vue> (component: VueClass<V>, options?: ThisTypedMountOptions<V>): Wrapper<V>
Expand Down