You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by da...@apache.org on 2017/07/26 06:46:10 UTC

[07/12] incubator-weex git commit: + [html5] add animation unit test case

+ [html5] add animation 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/0ed7a9cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/0ed7a9cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/0ed7a9cf

Branch: refs/heads/0.16-dev
Commit: 0ed7a9cf5619c7992c2d0b61fd83e2759ecf0986
Parents: 6f74e00
Author: erha19 <fa...@gmail.com>
Authored: Tue Jul 25 21:15:49 2017 +0800
Committer: erha19 <fa...@gmail.com>
Committed: Tue Jul 25 21:15:49 2017 +0800

----------------------------------------------------------------------
 html5/test/render/vue/modules/animation.js | 58 +++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0ed7a9cf/html5/test/render/vue/modules/animation.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/animation.js b/html5/test/render/vue/modules/animation.js
new file mode 100644
index 0000000..ff559f7
--- /dev/null
+++ b/html5/test/render/vue/modules/animation.js
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*global Event*/
+import * as animations from '../../../../render/vue/modules/animation'
+
+describe('animation module', () => {
+  it('should transition be worked', (done) => {
+    const { transition } = animations.default
+    const config = {
+      duration: 100,
+      timingFunction: 'ease',
+      delay: 100,
+      styles: {
+        position: 'absolute',
+        'align-items': 'center',
+        flex: 3,
+        width: '100%',
+        transform: 'translate(10px, 6px, 0)',
+        'border-top-width': '1px',
+        top: 0,
+        'margin-left': '-10px'
+      }
+    }
+    const vnode = { $el: document.createElement('div') }
+    const callback = sinon.spy()
+    const transitionValue = `all ${config.duration}ms ${config.timingFunction} ${config.delay}ms`
+    transition([vnode], config, callback)
+    expect(vnode.$el.style.transition).to.be.equal(transitionValue)
+    vnode.$el.dispatchEvent(new Event('transitionend'))
+    expect(vnode.$el.style.transition).to.be.equal('')
+    expect(callback.called).to.be.true
+    setTimeout(() => {
+        expect(vnode.$el.style.position).to.be.equal(config.styles.position)
+        expect(vnode.$el.style['-webkit-box-align']).to.be.equal(config.styles['align-items'])
+        expect(vnode.$el.style['-webkit-align-items']).to.be.equal(config.styles['align-items'])
+        expect(vnode.$el.style['-webkit-box-flex']).to.be.equal(config.styles.flex+'')
+        expect(vnode.$el.style.top).to.be.equal(config.styles.top + 'px')
+        expect(vnode.$el.style['margin-left']).to.be.equal('0px')
+        done()
+    },100)
+  })
+})