From 14c40e6af2517b5a058f84d8cea51a711d929924 Mon Sep 17 00:00:00 2001 From: 38elements <38elements@users.noreply.github.com> Date: Wed, 9 May 2018 20:28:08 +0900 Subject: [PATCH] fix(types): improve types (#593) --- packages/server-test-utils/types/index.d.ts | 7 +++-- .../types/test/renderToString.ts | 29 +++++++++++++++++-- packages/test-utils/types/index.d.ts | 7 +++-- packages/test-utils/types/test/mount.ts | 29 +++++++++++++++++-- 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/packages/server-test-utils/types/index.d.ts b/packages/server-test-utils/types/index.d.ts index 3a0f5b0a0..26bf401ae 100644 --- a/packages/server-test-utils/types/index.d.ts +++ b/packages/server-test-utils/types/index.d.ts @@ -34,8 +34,8 @@ interface MountOptions extends ComponentOptions { slots?: Slots scopedSlots?: Record stubs?: Stubs, - attrs?: object - listeners?: object + attrs?: Record + listeners?: Record sync?: boolean } @@ -47,6 +47,9 @@ type ThisTypedShallowOptions = ShallowOptions & ThisType interface VueTestUtilsConfigOptions { stubs?: Stubs + mocks?: object + methods?: Record + provide?: object } export declare let config: VueTestUtilsConfigOptions diff --git a/packages/server-test-utils/types/test/renderToString.ts b/packages/server-test-utils/types/test/renderToString.ts index 0a36c04d5..6c463d128 100644 --- a/packages/server-test-utils/types/test/renderToString.ts +++ b/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({}) @@ -17,12 +17,35 @@ renderToString(ClassComponent, { foo: normalOptions, bar: functionalOptions, baz: ClassComponent, - qux: `
Test
` + qux: `
Test
`, + quux: true }, attrs: { attribute: 'attr' }, listeners: { - listener: () => {} + listener: () => {}, + listeners: [() => {}, () => {}] } }) + +/** + * Test for config + */ +config.stubs = ['a'] +config.stubs = { + foo: normalOptions, + bar: functionalOptions, + baz: ClassComponent, + qux: `
Test
`, + quux: true +} +config.mocks = { + foo: 'bar', +} +config.methods = { + foo: () => {} +} +config.provide = { + foo: {} +} diff --git a/packages/test-utils/types/index.d.ts b/packages/test-utils/types/index.d.ts index e097ca593..c0c0100df 100644 --- a/packages/test-utils/types/index.d.ts +++ b/packages/test-utils/types/index.d.ts @@ -124,8 +124,8 @@ interface MountOptions extends ComponentOptions { slots?: Slots scopedSlots?: Record stubs?: Stubs, - attrs?: object - listeners?: object + attrs?: Record + listeners?: Record sync?: boolean } @@ -137,6 +137,9 @@ type ThisTypedShallowMountOptions = ShallowMountOptions & This interface VueTestUtilsConfigOptions { stubs?: Stubs + mocks?: object + methods?: Record + provide?: object } export declare function createLocalVue (): typeof Vue diff --git a/packages/test-utils/types/test/mount.ts b/packages/test-utils/types/test/mount.ts index 1a49fd6b0..890158cf3 100644 --- a/packages/test-utils/types/test/mount.ts +++ b/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' /** @@ -40,13 +40,15 @@ mount(ClassComponent, { foo: normalOptions, bar: functionalOptions, baz: ClassComponent, - qux: `
Test
` + qux: `
Test
`, + quux: true }, attrs: { attribute: 'attr' }, listeners: { - listener: () => {} + listener: () => {}, + listeners: [() => {}, () => {}] }, sync: true }) @@ -69,3 +71,24 @@ mount(ClassComponent, { this.bar } }) + +/** + * Test for config + */ +config.stubs = ['a'] +config.stubs = { + foo: normalOptions, + bar: functionalOptions, + baz: ClassComponent, + qux: `
Test
`, + quux: true +} +config.mocks = { + foo: 'bar', +} +config.methods = { + foo: () => {} +} +config.provide = { + foo: {} +}