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): improve types #593

Merged
merged 1 commit into from
May 9, 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
7 changes: 5 additions & 2 deletions packages/server-test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
slots?: Slots
scopedSlots?: Record<string, string>
stubs?: Stubs,
attrs?: object
listeners?: object
attrs?: Record<string, string>
listeners?: Record<string, Function | Function[]>
sync?: boolean
}

Expand All @@ -47,6 +47,9 @@ type ThisTypedShallowOptions<V extends Vue> = ShallowOptions<V> & ThisType<V>

interface VueTestUtilsConfigOptions {
stubs?: Stubs
mocks?: object
methods?: Record<string, Function>
provide?: object
}

export declare let config: VueTestUtilsConfigOptions
Expand Down
29 changes: 26 additions & 3 deletions packages/server-test-utils/types/test/renderToString.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { renderToString } from '../'
import { renderToString, config } from '../'
import { normalOptions, functionalOptions, Normal, ClassComponent } from './resources'

const store = new Vuex.Store({})
Expand All @@ -17,12 +17,35 @@ renderToString(ClassComponent, {
foo: normalOptions,
bar: functionalOptions,
baz: ClassComponent,
qux: `<div>Test</div>`
qux: `<div>Test</div>`,
quux: true
},
attrs: {
attribute: 'attr'
},
listeners: {
listener: () => {}
listener: () => {},
listeners: [() => {}, () => {}]
}
})

/**
* Test for config
*/
config.stubs = ['a']
config.stubs = {
foo: normalOptions,
bar: functionalOptions,
baz: ClassComponent,
qux: `<div>Test</div>`,
quux: true
}
config.mocks = {
foo: 'bar',
}
config.methods = {
foo: () => {}
}
config.provide = {
foo: {}
}
7 changes: 5 additions & 2 deletions packages/test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
slots?: Slots
scopedSlots?: Record<string, string>
stubs?: Stubs,
attrs?: object
listeners?: object
attrs?: Record<string, string>
listeners?: Record<string, Function | Function[]>
sync?: boolean
}

Expand All @@ -137,6 +137,9 @@ type ThisTypedShallowMountOptions<V extends Vue> = ShallowMountOptions<V> & This

interface VueTestUtilsConfigOptions {
stubs?: Stubs
mocks?: object
methods?: Record<string, Function>
provide?: object
}

export declare function createLocalVue (): typeof Vue
Expand Down
29 changes: 26 additions & 3 deletions packages/test-utils/types/test/mount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { mount, createLocalVue } from '../'
import { mount, createLocalVue, config } from '../'
import { normalOptions, functionalOptions, Normal, ClassComponent } from './resources'

/**
Expand Down Expand Up @@ -40,13 +40,15 @@ mount(ClassComponent, {
foo: normalOptions,
bar: functionalOptions,
baz: ClassComponent,
qux: `<div>Test</div>`
qux: `<div>Test</div>`,
quux: true
},
attrs: {
attribute: 'attr'
},
listeners: {
listener: () => {}
listener: () => {},
listeners: [() => {}, () => {}]
},
sync: true
})
Expand All @@ -69,3 +71,24 @@ mount(ClassComponent, {
this.bar
}
})

/**
* Test for config
*/
config.stubs = ['a']
config.stubs = {
foo: normalOptions,
bar: functionalOptions,
baz: ClassComponent,
qux: `<div>Test</div>`,
quux: true
}
config.mocks = {
foo: 'bar',
}
config.methods = {
foo: () => {}
}
config.provide = {
foo: {}
}