wip: error handling and nextTick for time slicing

This commit is contained in:
Evan You
2018-11-02 06:08:33 +09:00
parent d5862d8c51
commit d70b7d6dd5
13 changed files with 286 additions and 191 deletions

View File

@@ -12,7 +12,7 @@ import {
observable,
resetOps,
serialize,
renderIntsance,
renderInstance,
triggerEvent
} from '../src'
@@ -171,7 +171,7 @@ describe('test renderer', () => {
)
}
}
const app = renderIntsance(App)
const app = await renderInstance(App)
triggerEvent(app.$el, 'click')
expect(app.count).toBe(1)
await nextTick()

View File

@@ -15,7 +15,7 @@ const { render: _render } = createRenderer({
type publicRender = (
node: {} | null,
container: TestElement
) => Component | null
) => Promise<Component | null>
export const render = _render as publicRender
export function createInstance<T extends Component>(
@@ -25,10 +25,10 @@ export function createInstance<T extends Component>(
return createComponentInstance(h(Class, props)).$proxy as any
}
export function renderIntsance<T extends Component>(
export function renderInstance<T extends Component>(
Class: new () => T,
props?: any
): T {
): Promise<T> {
return render(h(Class, props), nodeOps.createElement('div')) as any
}