Skip to content

Commit

Permalink
fix(types): improve types (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
38elements authored and eddyerburgh committed May 9, 2018
1 parent 55a4391 commit 14c40e6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 10 deletions.
7 changes: 5 additions & 2 deletions packages/server-test-utils/types/index.d.ts
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
@@ -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
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
@@ -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: {}
}

0 comments on commit 14c40e6

Please sign in to comment.