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

@@ -44,7 +44,7 @@ describe('attribute fallthrough', () => {
const root = document.createElement('div')
document.body.appendChild(root)
render(h(Hello), root)
await render(h(Hello), root)
const node = root.children[0] as HTMLElement
@@ -110,7 +110,7 @@ describe('attribute fallthrough', () => {
const root = document.createElement('div')
document.body.appendChild(root)
render(h(Hello), root)
await render(h(Hello), root)
const node = root.children[0] as HTMLElement
@@ -190,7 +190,7 @@ describe('attribute fallthrough', () => {
const root = document.createElement('div')
document.body.appendChild(root)
render(h(Hello), root)
await render(h(Hello), root)
const node = root.children[0] as HTMLElement

View File

@@ -1,5 +1,5 @@
import { withHooks, useState, h, nextTick, useEffect, Component } from '../src'
import { renderIntsance, serialize, triggerEvent } from '@vue/runtime-test'
import { renderInstance, serialize, triggerEvent } from '@vue/runtime-test'
describe('hooks', () => {
it('useState', async () => {
@@ -16,7 +16,7 @@ describe('hooks', () => {
)
})
const counter = renderIntsance(Counter)
const counter = await renderInstance(Counter)
expect(serialize(counter.$el)).toBe(`<div>0</div>`)
triggerEvent(counter.$el, 'click')
@@ -40,7 +40,7 @@ describe('hooks', () => {
}
}
const counter = renderIntsance(Counter)
const counter = await renderInstance(Counter)
expect(serialize(counter.$el)).toBe(`<div>0</div>`)
triggerEvent(counter.$el, 'click')
@@ -71,7 +71,7 @@ describe('hooks', () => {
}
}
const counter = renderIntsance(Counter)
const counter = await renderInstance(Counter)
expect(serialize(counter.$el)).toBe(`<div>0</div>`)
triggerEvent(counter.$el, 'click')
@@ -98,7 +98,7 @@ describe('hooks', () => {
)
})
const counter = renderIntsance(Counter)
const counter = await renderInstance(Counter)
expect(effect).toBe(0)
triggerEvent(counter.$el, 'click')
await nextTick()

View File

@@ -7,7 +7,7 @@ import {
ComponentPropsOptions,
ComponentWatchOptions
} from '@vue/runtime-core'
import { createInstance, renderIntsance } from '@vue/runtime-test'
import { createInstance, renderInstance } from '@vue/runtime-test'
describe('class inheritance', () => {
it('should merge data', () => {
@@ -136,7 +136,7 @@ describe('class inheritance', () => {
}
}
const container = renderIntsance(Container)
const container = await renderInstance(Container)
expect(calls).toEqual([
'base beforeCreate',
'child beforeCreate',
@@ -200,7 +200,7 @@ describe('class inheritance', () => {
}
}
const container = renderIntsance(Container)
const container = await renderInstance(Container)
expect(container.$el.text).toBe('foo')
container.ok = false

View File

@@ -1,5 +1,5 @@
import { h, Component, memoize, nextTick } from '../src'
import { renderIntsance, serialize } from '@vue/runtime-test'
import { renderInstance, serialize } from '@vue/runtime-test'
describe('memoize', () => {
it('should work', async () => {
@@ -16,7 +16,7 @@ describe('memoize', () => {
}
}
const app = renderIntsance(App)
const app = await renderInstance(App)
expect(serialize(app.$el)).toBe(`<div>1<div>A1</div><div>B1</div></div>`)
app.count++
@@ -38,7 +38,7 @@ describe('memoize', () => {
}
}
const app = renderIntsance(App)
const app = await renderInstance(App)
expect(serialize(app.$el)).toBe(`<div>2</div>`)
app.foo++

View File

@@ -40,7 +40,7 @@ describe('Parent chain management', () => {
}
const root = nodeOps.createElement('div')
const parent = render(h(Parent), root) as Component
const parent = (await render(h(Parent), root)) as Component
expect(child.$parent).toBe(parent)
expect(child.$root).toBe(parent)
@@ -99,7 +99,7 @@ describe('Parent chain management', () => {
}
const root = nodeOps.createElement('div')
const parent = render(h(Parent), root) as Component
const parent = (await render(h(Parent), root)) as Component
expect(child.$parent).toBe(parent)
expect(child.$root).toBe(parent)