]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: layout test references
authorEvan You <yyx990803@gmail.com>
Fri, 23 Aug 2019 02:15:39 +0000 (22:15 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 23 Aug 2019 02:15:39 +0000 (22:15 -0400)
packages/runtime-core/__tests__/apiInject.spec.ts
packages/runtime-core/__tests__/apiLifecycle.spec.ts
packages/runtime-core/__tests__/apiSetupContext.spec.ts [new file with mode: 0644]
packages/runtime-core/__tests__/apiWatch.spec.ts
packages/runtime-core/__tests__/vdomChildren.spec.ts
packages/runtime-core/__tests__/vdomFragment.spec.ts

index b8c7bf6244320826ae628248c5c6beda6e9203f6..bcb6110cd7632f91268509c6d505925e9b37bc23 100644 (file)
@@ -1 +1,3 @@
+// reference: https://vue-composition-api-rfc.netlify.com/api.html#provide-inject
+
 describe('api: provide/inject', () => {})
index bd1ccf5ac98217701d75e841250c80478a141aa2..40b2e58dd222e16b375a3f218952b4fae7927592 100644 (file)
@@ -1 +1,3 @@
+// reference: https://vue-composition-api-rfc.netlify.com/api.html#lifecycle-hooks
+
 describe('api: lifecycle hooks', () => {})
diff --git a/packages/runtime-core/__tests__/apiSetupContext.spec.ts b/packages/runtime-core/__tests__/apiSetupContext.spec.ts
new file mode 100644 (file)
index 0000000..a27755a
--- /dev/null
@@ -0,0 +1,3 @@
+// reference: https://vue-composition-api-rfc.netlify.com/api.html#setup
+
+describe('api: setup context', () => {})
index 0c8316d9b76c8bb3eec2386934bc50ee55537d5e..46c3bba1212d99607436db710a4315b731adea9f 100644 (file)
@@ -1 +1,3 @@
+// reference: https://vue-composition-api-rfc.netlify.com/api.html#watch
+
 describe('api: watch', () => {})
index 84ec5614cc203f60aaf5126798174be8f9fc0b15..e16e62f9c9dea790141ee89e721e00d6eed5fa40 100644 (file)
@@ -1,3 +1,5 @@
+// reference: https://github.com/vuejs/vue/blob/dev/test/unit/modules/vdom/patch/children.spec.js
+
 describe('vdom: unkeyed children', () => {
   test.todo('append')
 
index 72f948f46ba1233aefbd6c72f39d23e0f02a8513..f9732864a937425c0731cd03116b4fc4ef55ffb7 100644 (file)
-import {
-  createVNode as h,
-  render,
-  nodeOps,
-  NodeTypes,
-  TestElement,
-  Fragment,
-  reactive,
-  serialize,
-  nextTick,
-  resetOps,
-  dumpOps,
-  NodeOpTypes
-} from '@vue/runtime-test'
-
-describe('vdom: fragment', () => {
-  it('should allow returning multiple component root nodes', async () => {
-    class App extends Component {
-      render() {
-        return [h('div', 'one'), 'two']
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-    expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
-    expect(root.children.length).toBe(2)
-    expect(root.children[0]).toMatchObject({
-      type: NodeTypes.ELEMENT,
-      tag: 'div'
-    })
-    expect((root.children[0] as TestElement).children[0]).toMatchObject({
-      type: NodeTypes.TEXT,
-      text: 'one'
-    })
-    expect(root.children[1]).toMatchObject({
-      type: NodeTypes.TEXT,
-      text: 'two'
-    })
-  })
-
-  it('should be able to explicitly create fragments', async () => {
-    class App extends Component {
-      render() {
-        return h('div', [h(Fragment, [h('div', 'one'), 'two'])])
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-    const parent = root.children[0] as TestElement
-    expect(serialize(parent)).toBe(`<div><div>one</div>two</div>`)
-  })
-
-  it('should be able to patch fragment children (unkeyed)', async () => {
-    const state = observable({ ok: true })
-    class App extends Component {
-      render() {
-        return state.ok
-          ? createFragment(
-              [h('div', 'one'), createTextVNode('two')],
-              ChildrenFlags.NONE_KEYED_VNODES
-            )
-          : createFragment(
-              [h('div', 'foo'), createTextVNode('bar'), createTextVNode('baz')],
-              ChildrenFlags.NONE_KEYED_VNODES
-            )
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-
-    expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
-
-    state.ok = false
-    await nextTick()
-    expect(serialize(root)).toBe(`<div><div>foo</div>barbaz</div>`)
-  })
-
-  it('should be able to patch fragment children (implicitly keyed)', async () => {
-    const state = observable({ ok: true })
-    class App extends Component {
-      render() {
-        return state.ok
-          ? [h('div', 'one'), 'two']
-          : [h('pre', 'foo'), 'bar', 'baz']
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await await render(h(App), root)
-
-    expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
-
-    state.ok = false
-    await nextTick()
-    expect(serialize(root)).toBe(`<div><pre>foo</pre>barbaz</div>`)
-  })
-
-  it('should be able to patch fragment children (explcitly keyed)', async () => {
-    const state = observable({ ok: true })
-    class App extends Component {
-      render() {
-        return state.ok
-          ? [h('div', { key: 1 }, 'one'), h('div', { key: 2 }, 'two')]
-          : [h('div', { key: 2 }, 'two'), h('div', { key: 1 }, 'one')]
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-
-    expect(serialize(root)).toBe(`<div><div>one</div><div>two</div></div>`)
-
-    resetOps()
-    state.ok = false
-    await nextTick()
-    expect(serialize(root)).toBe(`<div><div>two</div><div>one</div></div>`)
-    const ops = dumpOps()
-    // should be moving nodes instead of re-creating them
-    expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
-  })
-
-  it('should be able to move fragment', async () => {
-    const state = observable({ ok: true })
-    class App extends Component {
-      render() {
-        return state.ok
-          ? h('div', [
-              h('div', { key: 1 }, 'outer'),
-              h(Fragment, { key: 2 }, [
-                h('div', { key: 1 }, 'one'),
-                h('div', { key: 2 }, 'two')
-              ])
-            ])
-          : h('div', [
-              h(Fragment, { key: 2 }, [
-                h('div', { key: 2 }, 'two'),
-                h('div', { key: 1 }, 'one')
-              ]),
-              h('div', { key: 1 }, 'outer')
-            ])
-      }
-    }
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-    const parent = root.children[0] as TestElement
-
-    expect(serialize(parent)).toBe(
-      `<div><div>outer</div><div>one</div><div>two</div></div>`
-    )
-
-    resetOps()
-    state.ok = false
-    await nextTick()
-    expect(serialize(parent)).toBe(
-      `<div><div>two</div><div>one</div><div>outer</div></div>`
-    )
-    const ops = dumpOps()
-    // should be moving nodes instead of re-creating them
-    expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
-  })
-
-  it('should be able to handle nested fragments', async () => {
-    const state = observable({ ok: true })
-    class App extends Component {
-      render() {
-        return state.ok
-          ? [
-              h('div', { key: 1 }, 'outer'),
-              h(Fragment, { key: 2 }, [
-                h('div', { key: 1 }, 'one'),
-                h('div', { key: 2 }, 'two')
-              ])
-            ]
-          : [
-              h(Fragment, { key: 2 }, [
-                h('div', { key: 2 }, 'two'),
-                h('div', { key: 1 }, 'one')
-              ]),
-              h('div', { key: 1 }, 'outer')
-            ]
-      }
-    }
-
-    const root = nodeOps.createElement('div')
-    await render(h(App), root)
-
-    expect(serialize(root)).toBe(
-      `<div><div>outer</div><div>one</div><div>two</div></div>`
-    )
-
-    resetOps()
-    state.ok = false
-    await nextTick()
-    expect(serialize(root)).toBe(
-      `<div><div>two</div><div>one</div><div>outer</div></div>`
-    )
-    const ops = dumpOps()
-    // should be moving nodes instead of re-creating them
-    expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
-  })
-})
+// These tests are outdated.
+
+// import {
+//   createVNode as h,
+//   render,
+//   nodeOps,
+//   NodeTypes,
+//   TestElement,
+//   Fragment,
+//   reactive,
+//   serialize,
+//   nextTick,
+//   resetOps,
+//   dumpOps,
+//   NodeOpTypes
+// } from '@vue/runtime-test'
+
+// describe('vdom: fragment', () => {
+//   it('should allow returning multiple component root nodes', async () => {
+//     class App extends Component {
+//       render() {
+//         return [h('div', 'one'), 'two']
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+//     expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
+//     expect(root.children.length).toBe(2)
+//     expect(root.children[0]).toMatchObject({
+//       type: NodeTypes.ELEMENT,
+//       tag: 'div'
+//     })
+//     expect((root.children[0] as TestElement).children[0]).toMatchObject({
+//       type: NodeTypes.TEXT,
+//       text: 'one'
+//     })
+//     expect(root.children[1]).toMatchObject({
+//       type: NodeTypes.TEXT,
+//       text: 'two'
+//     })
+//   })
+
+//   it('should be able to explicitly create fragments', async () => {
+//     class App extends Component {
+//       render() {
+//         return h('div', [h(Fragment, [h('div', 'one'), 'two'])])
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+//     const parent = root.children[0] as TestElement
+//     expect(serialize(parent)).toBe(`<div><div>one</div>two</div>`)
+//   })
+
+//   it('should be able to patch fragment children (unkeyed)', async () => {
+//     const state = observable({ ok: true })
+//     class App extends Component {
+//       render() {
+//         return state.ok
+//           ? createFragment(
+//               [h('div', 'one'), createTextVNode('two')],
+//               ChildrenFlags.NONE_KEYED_VNODES
+//             )
+//           : createFragment(
+//               [h('div', 'foo'), createTextVNode('bar'), createTextVNode('baz')],
+//               ChildrenFlags.NONE_KEYED_VNODES
+//             )
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+
+//     expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
+
+//     state.ok = false
+//     await nextTick()
+//     expect(serialize(root)).toBe(`<div><div>foo</div>barbaz</div>`)
+//   })
+
+//   it('should be able to patch fragment children (implicitly keyed)', async () => {
+//     const state = observable({ ok: true })
+//     class App extends Component {
+//       render() {
+//         return state.ok
+//           ? [h('div', 'one'), 'two']
+//           : [h('pre', 'foo'), 'bar', 'baz']
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await await render(h(App), root)
+
+//     expect(serialize(root)).toBe(`<div><div>one</div>two</div>`)
+
+//     state.ok = false
+//     await nextTick()
+//     expect(serialize(root)).toBe(`<div><pre>foo</pre>barbaz</div>`)
+//   })
+
+//   it('should be able to patch fragment children (explcitly keyed)', async () => {
+//     const state = observable({ ok: true })
+//     class App extends Component {
+//       render() {
+//         return state.ok
+//           ? [h('div', { key: 1 }, 'one'), h('div', { key: 2 }, 'two')]
+//           : [h('div', { key: 2 }, 'two'), h('div', { key: 1 }, 'one')]
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+
+//     expect(serialize(root)).toBe(`<div><div>one</div><div>two</div></div>`)
+
+//     resetOps()
+//     state.ok = false
+//     await nextTick()
+//     expect(serialize(root)).toBe(`<div><div>two</div><div>one</div></div>`)
+//     const ops = dumpOps()
+//     // should be moving nodes instead of re-creating them
+//     expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
+//   })
+
+//   it('should be able to move fragment', async () => {
+//     const state = observable({ ok: true })
+//     class App extends Component {
+//       render() {
+//         return state.ok
+//           ? h('div', [
+//               h('div', { key: 1 }, 'outer'),
+//               h(Fragment, { key: 2 }, [
+//                 h('div', { key: 1 }, 'one'),
+//                 h('div', { key: 2 }, 'two')
+//               ])
+//             ])
+//           : h('div', [
+//               h(Fragment, { key: 2 }, [
+//                 h('div', { key: 2 }, 'two'),
+//                 h('div', { key: 1 }, 'one')
+//               ]),
+//               h('div', { key: 1 }, 'outer')
+//             ])
+//       }
+//     }
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+//     const parent = root.children[0] as TestElement
+
+//     expect(serialize(parent)).toBe(
+//       `<div><div>outer</div><div>one</div><div>two</div></div>`
+//     )
+
+//     resetOps()
+//     state.ok = false
+//     await nextTick()
+//     expect(serialize(parent)).toBe(
+//       `<div><div>two</div><div>one</div><div>outer</div></div>`
+//     )
+//     const ops = dumpOps()
+//     // should be moving nodes instead of re-creating them
+//     expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
+//   })
+
+//   it('should be able to handle nested fragments', async () => {
+//     const state = observable({ ok: true })
+//     class App extends Component {
+//       render() {
+//         return state.ok
+//           ? [
+//               h('div', { key: 1 }, 'outer'),
+//               h(Fragment, { key: 2 }, [
+//                 h('div', { key: 1 }, 'one'),
+//                 h('div', { key: 2 }, 'two')
+//               ])
+//             ]
+//           : [
+//               h(Fragment, { key: 2 }, [
+//                 h('div', { key: 2 }, 'two'),
+//                 h('div', { key: 1 }, 'one')
+//               ]),
+//               h('div', { key: 1 }, 'outer')
+//             ]
+//       }
+//     }
+
+//     const root = nodeOps.createElement('div')
+//     await render(h(App), root)
+
+//     expect(serialize(root)).toBe(
+//       `<div><div>outer</div><div>one</div><div>two</div></div>`
+//     )
+
+//     resetOps()
+//     state.ok = false
+//     await nextTick()
+//     expect(serialize(root)).toBe(
+//       `<div><div>two</div><div>one</div><div>outer</div></div>`
+//     )
+//     const ops = dumpOps()
+//     // should be moving nodes instead of re-creating them
+//     expect(ops.some(op => op.type === NodeOpTypes.CREATE)).toBe(false)
+//   })
+// })