Skip to content

Commit d99637b

Browse files
committed
[weex] make tests pass
1 parent 53d0592 commit d99637b

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/platforms/weex/framework.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export function createInstance (
114114
* @param {string} instanceId
115115
*/
116116
export function destroyInstance (instanceId) {
117-
const instance = instances[instanceId] || {}
118-
if (instance.app instanceof instance.Vue) {
117+
const instance = instances[instanceId]
118+
if (instance && instance.app instanceof instance.Vue) {
119119
instance.app.$destroy()
120120
}
121121
delete instances[instanceId]
@@ -129,8 +129,8 @@ export function destroyInstance (instanceId) {
129129
* @param {object} data
130130
*/
131131
export function refreshInstance (instanceId, data) {
132-
const instance = instances[instanceId] || {}
133-
if (!(instance.app instanceof instance.Vue)) {
132+
const instance = instances[instanceId]
133+
if (!instance || !(instance.app instanceof instance.Vue)) {
134134
return new Error(`refreshInstance: instance ${instanceId} not found!`)
135135
}
136136
for (const key in data) {
@@ -145,8 +145,8 @@ export function refreshInstance (instanceId, data) {
145145
* @param {string} instanceId
146146
*/
147147
export function getRoot (instanceId) {
148-
const instance = instances[instanceId] || {}
149-
if (!(instance.app instanceof instance.Vue)) {
148+
const instance = instances[instanceId]
149+
if (!instance || !(instance.app instanceof instance.Vue)) {
150150
return new Error(`getRoot: instance ${instanceId} not found!`)
151151
}
152152
return instance.app.$el.toJSON()
@@ -160,8 +160,8 @@ export function getRoot (instanceId) {
160160
* @param {array} tasks
161161
*/
162162
export function receiveTasks (instanceId, tasks) {
163-
const instance = instances[instanceId] || {}
164-
if (!(instance.app instanceof instance.Vue)) {
163+
const instance = instances[instanceId]
164+
if (!instance || !(instance.app instanceof instance.Vue)) {
165165
return new Error(`receiveTasks: instance ${instanceId} not found!`)
166166
}
167167
const { callbacks, document } = instance
@@ -275,7 +275,6 @@ function createVueModuleInstance (instanceId, moduleGetter) {
275275
* @return {object}
276276
*/
277277
Vue.prototype.$getConfig = function () {
278-
const instance = instances[this.$instanceId] || {}
279278
if (instance.app instanceof Vue) {
280279
return instance.config
281280
}

test/weex/runtime/framework.spec.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,6 @@ describe('framework APIs', () => {
608608
type: 'div',
609609
children: [{ type: 'text', attr: { value: 'Hello' }}]
610610
})
611-
// ensure base Vue is unaffected
612-
expect(framework.Vue.options.components.test).toBeUndefined()
613611
})
614612

615613
it('adding prototype methods', () => {
@@ -632,8 +630,6 @@ describe('framework APIs', () => {
632630
type: 'div',
633631
children: [{ type: 'text', attr: { value: 'Hello' }}]
634632
})
635-
// ensure base Vue is unaffected
636-
expect(framework.Vue.prototype.$test).toBeUndefined()
637633
})
638634

639635
it('using global mixins', () => {
@@ -662,9 +658,5 @@ describe('framework APIs', () => {
662658
type: 'div',
663659
children: [{ type: 'text', attr: { value: 'Hello' }}]
664660
})
665-
const vm = new framework.Vue({
666-
data: { test: false }
667-
})
668-
expect(vm.test).toBe(false)
669661
})
670662
})

0 commit comments

Comments
 (0)