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:11 UTC

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

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

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

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


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/0a02f236/html5/test/render/vue/modules/globalEvent.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/globalEvent.js b/html5/test/render/vue/modules/globalEvent.js
new file mode 100644
index 0000000..8455295
--- /dev/null
+++ b/html5/test/render/vue/modules/globalEvent.js
@@ -0,0 +1,42 @@
+/*
+ * 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 globalEvent from '../../../../render/vue/modules/globalEvent'
+
+describe('globalEvent module', () => {
+  const callback = sinon.spy()
+  it('should addEventListener be worked', () => {
+      const { addEventListener } = globalEvent.default
+      const event = 'click'
+      expect(addEventListener).to.be.a('function')
+      addEventListener(event, callback)
+      expect(callback.called).to.be.false
+      document.dispatchEvent(new Event(event))
+      expect(callback.called).to.be.true
+      expect(callback.callCount).to.be.equal(1)
+  })
+  it('should removeEventListener be worked', () => {
+      const { removeEventListener } = globalEvent.default
+      const event = 'click'
+      expect(removeEventListener).to.be.a('function')
+      removeEventListener(event)
+      document.dispatchEvent(new Event(event))
+      expect(callback.callCount).to.be.equal(1)
+  })
+})
\ No newline at end of file