wip: trying to make tests work

This commit is contained in:
Evan You
2018-11-02 07:43:28 +09:00
parent d70b7d6dd5
commit ba571cda61
7 changed files with 53 additions and 45 deletions

View File

@@ -17,7 +17,7 @@ import {
} from '../src'
describe('test renderer', () => {
it('should work', () => {
it('should work', async () => {
class App extends Component {
render() {
return h(
@@ -30,7 +30,7 @@ describe('test renderer', () => {
}
}
const root = nodeOps.createElement('div')
render(h(App), root)
await render(h(App), root)
expect(root.children.length).toBe(1)
@@ -64,7 +64,7 @@ describe('test renderer', () => {
const root = nodeOps.createElement('div')
resetOps()
render(h(App), root)
await render(h(App), root)
const ops = dumpOps()
expect(ops.length).toBe(5)
@@ -126,7 +126,7 @@ describe('test renderer', () => {
})
})
it('should be able to serialize nodes', () => {
it('should be able to serialize nodes', async () => {
class App extends Component {
render() {
return h(
@@ -139,7 +139,7 @@ describe('test renderer', () => {
}
}
const root = nodeOps.createElement('div')
render(h(App), root)
await render(h(App), root)
expect(serialize(root)).toEqual(
`<div><div id="test"><span>foo</span>hello</div></div>`
)

View File

@@ -63,6 +63,9 @@ export function dumpOps(): NodeOp[] {
}
function createElement(tag: string): TestElement {
if (nodeId === 5) {
throw new Error('foo')
}
const node: TestElement = {
id: nodeId++,
type: NodeTypes.ELEMENT,