Skip to content
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

fix(types): update packages/test-utils/types/index.d.ts #522

Merged
merged 1 commit into from
Apr 10, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type RefSelector = {
ref: string
}

/**
* Utility type for name options object that can be used as a Selector
*/
type NameSelector = {
name: string
}

/**
* Base class of Wrapper and WrapperArray
* It has common methods on both Wrapper and WrapperArray
Expand All @@ -61,7 +68,6 @@ interface BaseWrapper {
isEmpty (): boolean
isVueInstance (): boolean

update (): void
setComputed (computed: object): void
setData (data: object): void
setMethods (data: object): void
Expand All @@ -80,12 +86,14 @@ export interface Wrapper<V extends Vue> extends BaseWrapper {
find (selector: FunctionalComponentOptions): Wrapper<Vue>
find (selector: string): Wrapper<Vue>
find (selector: RefSelector): Wrapper<Vue>
find (selector: NameSelector): Wrapper<Vue>

findAll<R extends Vue> (selector: VueClass<R>): WrapperArray<R>
findAll<R extends Vue> (selector: ComponentOptions<R>): WrapperArray<R>
findAll (selector: FunctionalComponentOptions): WrapperArray<Vue>
findAll (selector: string): WrapperArray<Vue>
findAll (selector: RefSelector): WrapperArray<Vue>
findAll (selector: NameSelector): WrapperArray<Vue>

html (): string
text (): string
Expand Down Expand Up @@ -116,6 +124,7 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
stubs?: Stubs,
attrs?: object
listeners?: object
sync?: boolean
}

type ThisTypedMountOptions<V extends Vue> = MountOptions<V> & ThisType<V>
Expand Down
3 changes: 2 additions & 1 deletion packages/test-utils/types/test/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ mount(ClassComponent, {
},
listeners: {
listener: () => {}
}
},
sync: true
})

mount(functionalOptions, {
Expand Down
4 changes: 4 additions & 0 deletions packages/test-utils/types/test/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ let found = wrapper.find('.foo')
found = wrapper.find(normalOptions)
found = wrapper.find(functionalOptions)
found = wrapper.find(ClassComponent)
found = wrapper.find({ ref: 'myButton' })
found = wrapper.find({ name: 'my-button' })

let array = wrapper.findAll('.bar')
array = wrapper.findAll(normalOptions)
array = wrapper.findAll(functionalOptions)
array = wrapper.findAll(ClassComponent)
array = wrapper.findAll({ ref: 'myButton' })
array = wrapper.findAll({ name: 'my-button' })

let str: string = wrapper.html()
str = wrapper.text()
Expand Down