* [html5] improve component unit test case

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/25947ddb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/25947ddb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/25947ddb

Branch: refs/heads/0.15-dev
Commit: 25947ddbbd07a605152340f9ff5ef75365f33259
Parents: 30a52ef
Author: erha19 <faterr...@gmail.com>
Authored: Mon Jul 17 20:49:59 2017 +0800
Committer: erha19 <faterr...@gmail.com>
Committed: Mon Jul 17 20:49:59 2017 +0800

----------------------------------------------------------------------
 html5/test/render/vue/utils/component.js | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/25947ddb/html5/test/render/vue/utils/component.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/utils/component.js 
b/html5/test/render/vue/utils/component.js
index fd97d5b..8248493 100644
--- a/html5/test/render/vue/utils/component.js
+++ b/html5/test/render/vue/utils/component.js
@@ -2,6 +2,7 @@ import { init } from '../helper/runtime'
 import div from '../../../../render/vue/components/div'
 
 import firstScreenAppearBundle from 
'../data/build/dotvue/first-screen-appear.js'
+import * as components from '../../../../render/vue/utils/component'
 
 init('utils component', (Vue, helper) => {
   const spys = {
@@ -14,14 +15,27 @@ init('utils component', (Vue, helper) => {
   }
 
   const id = 'test-first-screen-appear'
+  let vm = null
 
   before(() => {
     helper.register('div', div)
+    vm =helper.createVm(firstScreenAppearBundle, id)
   })
-
-  describe('watchAppear', function () {
+  
+  describe('component functions', () => {
+    it('getParentScroller', () => {
+      const { getParentScroller } = components
+      expect(getParentScroller).to.be.a('function')
+      expect(getParentScroller(vm)).to.be.a('undefined')
+    })
+    it('isComponentVisible', () => {
+      const { isComponentVisible } = components
+      expect(isComponentVisible).to.be.a('function')
+      expect(isComponentVisible(vm)).to.be.true
+    })
+  })
+  describe('watchAppear', () => {
     it('should work when mounted and updated.', function (done) {
-      helper.createVm(firstScreenAppearBundle, id)
       helper.registerDone(id, () => {
         const { appear: appearSpy, disappear: disappearSpy } = spys
         expect(appearSpy.callCount).to.equal(2)
@@ -32,8 +46,11 @@ init('utils component', (Vue, helper) => {
         expect(appearSpy.args[0][0].direction).to.not.exist
         expect(appearSpy.args[1][0].direction).to.not.exist
         expect(disappearSpy.args[0][0].direction).to.not.exist
-        helper.unregisterDone(id)
-        done()
+        window.dispatchEvent(new Event('scroll'))
+        setTimeout(() => {
+          helper.unregisterDone(id)
+          done()
+        },25)
       })
     })
   })

Reply via email to