|
@@ -76,6 +76,32 @@ describe('create-component', () => {
|
|
|
go()
|
|
go()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it('create a component when resolved with synchronous async loading', done => {
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ props: {},
|
|
|
|
|
+ staticAttrs: { class: 'bar' }
|
|
|
|
|
+ }
|
|
|
|
|
+ spyOn(vm, '$forceUpdate')
|
|
|
|
|
+ function async (resolve, reject) {
|
|
|
|
|
+ resolve({
|
|
|
|
|
+ name: 'child',
|
|
|
|
|
+ props: ['msg']
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ const vnode = createComponent(async, data, vm, vm)
|
|
|
|
|
+ expect(vnode.asyncFactory).toBe(async)
|
|
|
|
|
+ expect(vnode.asyncFactory.contexts.length).toEqual(0)
|
|
|
|
|
+ expect(vnode.tag).toMatch(/vue-component-[0-9]+-child/)
|
|
|
|
|
+ expect(vnode.data.staticAttrs).toEqual({ class: 'bar' })
|
|
|
|
|
+ expect(vnode.children).toBeUndefined()
|
|
|
|
|
+ expect(vnode.text).toBeUndefined()
|
|
|
|
|
+ expect(vnode.elm).toBeUndefined()
|
|
|
|
|
+ expect(vnode.ns).toBeUndefined()
|
|
|
|
|
+ expect(vnode.context).toEqual(vm)
|
|
|
|
|
+ expect(vm.$forceUpdate).not.toHaveBeenCalled()
|
|
|
|
|
+ done()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it('not create a component when rejected with async loading', done => {
|
|
it('not create a component when rejected with async loading', done => {
|
|
|
let vnode = null
|
|
let vnode = null
|
|
|
const data = {
|
|
const data = {
|