weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [11/13] incubator-weex git commit: * [html5] fix eslint error
Date Mon, 03 Jul 2017 03:45:00 GMT
* [html5] fix eslint error


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

Branch: refs/heads/0.15-dev
Commit: 7202cabb8304a158f3b59912c0e8099e2543867e
Parents: 4d7f0ff
Author: erha19 <faterrole@gmail.com>
Authored: Fri Jun 30 18:03:41 2017 +0800
Committer: erha19 <faterrole@gmail.com>
Committed: Fri Jun 30 18:03:41 2017 +0800

----------------------------------------------------------------------
 html5/test/render/vue/helper/utils.js      |  17 +-
 html5/test/render/vue/modules/modal.js     | 220 ++++++++++++------------
 html5/test/render/vue/modules/websocket.js | 167 +++++++++---------
 3 files changed, 198 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7202cabb/html5/test/render/vue/helper/utils.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/helper/utils.js b/html5/test/render/vue/helper/utils.js
index 2864ecc..01eb5ec 100644
--- a/html5/test/render/vue/helper/utils.js
+++ b/html5/test/render/vue/helper/utils.js
@@ -19,17 +19,16 @@
 /**
  * @fileOverview utils for tests.
  */
-
 export function toArray (list) {
   if (!list) return []
   return Array.prototype.slice.call(list)
 }
-//see https://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript
-export function nodeListToArray(obj) {
-  var array = [];
-  // iterate backwards ensuring that length is an UInt32
-  for (var i = obj.length >>> 0; i--;) { 
-    array[i] = obj[i];
+//  see https://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript
+export function nodeListToArray (obj) {
+  const array = []
+    // iterate backwards ensuring that length is an UInt32
+  for (let i = obj.length >>> 0; i--;) {
+    array[i] = obj[i]
   }
-  return array;
-}
\ No newline at end of file
+  return array
+}

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7202cabb/html5/test/render/vue/modules/modal.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/modal.js b/html5/test/render/vue/modules/modal.js
index b69c91a..a0e10f1 100644
--- a/html5/test/render/vue/modules/modal.js
+++ b/html5/test/render/vue/modules/modal.js
@@ -27,39 +27,39 @@ import {
 /** @test {webSocket module} */
 describe('modal module', function () {
   after(function (done) {
-    done();
-  });
+    done()
+  })
   describe('modal API', function () {
-    const modal = new Modal();
+    const modal = new Modal()
     it('should have prototype', function () {
-      expect(modal).to.have.property('show');
-      expect(modal).to.have.property('destroy');
-      expect(modal).to.have.property('createWrap');
-      expect(modal).to.have.property('createNode');
-      expect(modal).to.have.property('clearNode');
-      expect(modal).to.have.property('createNodeContent');
-      expect(modal).to.have.property('bindEvents');
+      expect(modal).to.have.property('show')
+      expect(modal).to.have.property('destroy')
+      expect(modal).to.have.property('createWrap')
+      expect(modal).to.have.property('createNode')
+      expect(modal).to.have.property('clearNode')
+      expect(modal).to.have.property('createNodeContent')
+      expect(modal).to.have.property('bindEvents')
     })
     it('wrap style should be weex-modal-wrap when show method is called', function () {
       // Modal
       // assert.strictEqual($modal[0], $el[0], 'collection contains element')
     })
-  });
+  })
   describe('toast API', function () {
-    const toast = Toast;
-    let config = {
+    const toast = Toast
+    const config = {
       message: 'Test',
       duration: 1
     }
     it('should have method', function () {
-      expect(toast.push).to.be.a('function');
-      expect(toast.show).to.be.a('function');
+      expect(toast.push).to.be.a('function')
+      expect(toast.show).to.be.a('function')
     })
     it('should toast mount on document when push method is called', function () {
-      const TOAST_WIN_CLASS_NAME = '.weex-toast';
-      let $Toast;
-      let clock = sinon.useFakeTimers();
-      toast.push(config.message, config.duration);
+      const TOAST_WIN_CLASS_NAME = '.weex-toast'
+      let $Toast = null
+      const clock = sinon.useFakeTimers()
+      toast.push(config.message, config.duration)
       $Toast = document.querySelector(TOAST_WIN_CLASS_NAME)
       expect($Toast.innerText, 'should contain Test message').to.be.equal(config.message)
       expect(nodeListToArray($Toast.classList), 'should include hide class').to.include('hide')
@@ -67,51 +67,51 @@ describe('modal module', function () {
       expect(nodeListToArray($Toast.classList), 'should remove hide class').to.not.include('hide')
     })
     it('call show method while toast queue length < 1', function () {
-      const TOAST_WIN_CLASS_NAME = '.weex-toast';
-      let $Toast;
-      toast.show();
+      const TOAST_WIN_CLASS_NAME = '.weex-toast'
+      let $Toast = null
+      toast.show()
       $Toast = document.querySelector(TOAST_WIN_CLASS_NAME)
-      expect($Toast, 'element should be null when toast quene length < 1').to.be.null;
+      expect($Toast, 'element should be null when toast quene length < 1').to.be.null
     })
-  });
+  })
   describe('alert API', function () {
-    let config = {
+    const config = {
       message: 'Test',
       callback: function () {}
     }
-    const alert = new Alert(config);
+    const alert = new Alert(config)
     it('extends Standard modal API', function () {
-      expect(alert).to.have.property('show');
-      expect(alert).to.have.property('destroy');
-      expect(alert).to.have.property('createWrap');
-      expect(alert).to.have.property('createNode');
-      expect(alert).to.have.property('clearNode');
-      expect(alert).to.have.property('createNodeContent');
-      expect(alert).to.have.property('bindEvents');
+      expect(alert).to.have.property('show')
+      expect(alert).to.have.property('destroy')
+      expect(alert).to.have.property('createWrap')
+      expect(alert).to.have.property('createNode')
+      expect(alert).to.have.property('clearNode')
+      expect(alert).to.have.property('createNodeContent')
+      expect(alert).to.have.property('bindEvents')
     })
     it('should have prototype', function () {
-      expect(alert).to.have.property('createNodeContent');
-      expect(alert).to.have.property('bindEvents');
+      expect(alert).to.have.property('createNodeContent')
+      expect(alert).to.have.property('bindEvents')
     })
     it('would alert mount on document when instance is created', function () {
-      const ALERT_WEEX_CLASS_NAME = '.weex-alert';
-      const ALERT_WEEX_MSG_CLASS_NAME = '.content-msg';
-      const BUTTON_CLASS = '.alert-ok';
-      let $Alert;
+      const ALERT_WEEX_CLASS_NAME = '.weex-alert'
+      const ALERT_WEEX_MSG_CLASS_NAME = '.content-msg'
+      const BUTTON_CLASS = '.alert-ok'
+      let $Alert = null
       $Alert = document.querySelector(ALERT_WEEX_CLASS_NAME)
-      let messageShouldBe = $Alert.querySelector(ALERT_WEEX_MSG_CLASS_NAME).innerText
-      let button = $Alert.querySelector(BUTTON_CLASS)
+      const messageShouldBe = $Alert.querySelector(ALERT_WEEX_MSG_CLASS_NAME).innerText
+      const button = $Alert.querySelector(BUTTON_CLASS)
       expect(messageShouldBe, 'should contain Test message').to.be.equal(config.message)
-      let event = document.createEvent('HTMLEvents');
-      event.initEvent("click", false, true);
-      button.dispatchEvent(event);
+      const event = document.createEvent('HTMLEvents')
+      event.initEvent('click', false, true)
+      button.dispatchEvent(event)
       $Alert = document.querySelector(ALERT_WEEX_CLASS_NAME)
-      expect($Alert, 'element would unmount while ok button is clicked').to.be.null;
+      expect($Alert, 'element would unmount while ok button is clicked').to.be.null
     })
-  });
+  })
   describe('confirm API', function () {
-    let callbackResult = '';
-    let config = {
+    let callbackResult = ''
+    const config = {
       message: 'Test',
       okTitle: 'ok',
       cancelTitle: 'cancel',
@@ -119,51 +119,51 @@ describe('modal module', function () {
         callbackResult = ret
       }
     }
-    let confirm = new Confirm(config);
+    let confirm = new Confirm(config)
     it('extends Standard modal API', function () {
-      expect(confirm).to.have.property('show');
-      expect(confirm).to.have.property('destroy');
-      expect(confirm).to.have.property('createWrap');
-      expect(confirm).to.have.property('createNode');
-      expect(confirm).to.have.property('clearNode');
-      expect(confirm).to.have.property('createNodeContent');
-      expect(confirm).to.have.property('bindEvents');
+      expect(confirm).to.have.property('show')
+      expect(confirm).to.have.property('destroy')
+      expect(confirm).to.have.property('createWrap')
+      expect(confirm).to.have.property('createNode')
+      expect(confirm).to.have.property('clearNode')
+      expect(confirm).to.have.property('createNodeContent')
+      expect(confirm).to.have.property('bindEvents')
     })
     it('should have prototype', function () {
-      expect(confirm.createNodeContent).to.be.a('function');
-      expect(confirm.bindEvents).to.be.a('function');
+      expect(confirm.createNodeContent).to.be.a('function')
+      expect(confirm.bindEvents).to.be.a('function')
     })
     it('would confirm mount on document when instance is created', function () {
-      const CONFIRM_WEEX_CLASS_NAME = '.weex-confirm';
-      const CONFIRM_WEEX_MSG_CLASS_NAME = '.content-msg';
-      const OK_BUTTON_CLASS = '.btn-ok';
-      const CANCEL_BUTTON_CLASS = '.btn-cancel';
-      let $CONFIRM;
+      const CONFIRM_WEEX_CLASS_NAME = '.weex-confirm'
+      const CONFIRM_WEEX_MSG_CLASS_NAME = '.content-msg'
+      const OK_BUTTON_CLASS = '.btn-ok'
+      const CANCEL_BUTTON_CLASS = '.btn-cancel'
+      let $CONFIRM = null
       $CONFIRM = document.querySelector(CONFIRM_WEEX_CLASS_NAME)
-      let messageShouldBe = $CONFIRM.querySelector(CONFIRM_WEEX_MSG_CLASS_NAME).innerText
+      const messageShouldBe = $CONFIRM.querySelector(CONFIRM_WEEX_MSG_CLASS_NAME).innerText
       let button = $CONFIRM.querySelector(OK_BUTTON_CLASS)
       expect(messageShouldBe, 'should contain Test message').to.be.equal(config.message)
-      let event = document.createEvent('HTMLEvents');
-      event.initEvent("click", false, true);
-      button.dispatchEvent(event);
+      let event = document.createEvent('HTMLEvents')
+      event.initEvent('click', false, true)
+      button.dispatchEvent(event)
       $CONFIRM = document.querySelector(CONFIRM_WEEX_CLASS_NAME)
-      expect($CONFIRM, 'element would unmount while ok button is clicked').to.be.null;
-      expect(callbackResult, 'callback would return okTitle').to.be.equal(config.okTitle);
-      //reopen confirm for test cancel button
-      confirm = new Confirm(config);
+      expect($CONFIRM, 'element would unmount while ok button is clicked').to.be.null
+      expect(callbackResult, 'callback would return okTitle').to.be.equal(config.okTitle)
+      //  reopen confirm for test cancel button
+      confirm = new Confirm(config)
       $CONFIRM = document.querySelector(CONFIRM_WEEX_CLASS_NAME)
       button = $CONFIRM.querySelector(CANCEL_BUTTON_CLASS)
-      event = document.createEvent('HTMLEvents');
-      event.initEvent("click", false, true);
-      button.dispatchEvent(event);
+      event = document.createEvent('HTMLEvents')
+      event.initEvent('click', false, true)
+      button.dispatchEvent(event)
       $CONFIRM = document.querySelector(CONFIRM_WEEX_CLASS_NAME)
-      expect($CONFIRM, 'element would unmount while ok button is clicked').to.be.null;
-      expect(callbackResult, 'callback would return okTitle').to.be.equal(config.cancelTitle);
+      expect($CONFIRM, 'element would unmount while ok button is clicked').to.be.null
+      expect(callbackResult, 'callback would return okTitle').to.be.equal(config.cancelTitle)
     })
-  });
+  })
   describe('prompt API', function () {
-    let callbackResult = '';
-    let config = {
+    let callbackResult = ''
+    const config = {
       message: 'Test',
       okTitle: 'ok',
       cancelTitle: 'cancel',
@@ -171,55 +171,55 @@ describe('modal module', function () {
         callbackResult = ret
       }
     }
-    let inputMessage = 'prompt message'
+    const inputMessage = 'prompt message'
     let prompt = new Prompt(config)
     it('extends Standard modal API', function () {
-      expect(prompt).to.have.property('show');
-      expect(prompt).to.have.property('destroy');
-      expect(prompt).to.have.property('createWrap');
-      expect(prompt).to.have.property('createNode');
-      expect(prompt).to.have.property('clearNode');
-      expect(prompt).to.have.property('createNodeContent');
-      expect(prompt).to.have.property('bindEvents');
+      expect(prompt).to.have.property('show')
+      expect(prompt).to.have.property('destroy')
+      expect(prompt).to.have.property('createWrap')
+      expect(prompt).to.have.property('createNode')
+      expect(prompt).to.have.property('clearNode')
+      expect(prompt).to.have.property('createNodeContent')
+      expect(prompt).to.have.property('bindEvents')
     })
     it('should have prototype', function () {
-      expect(prompt.createNodeContent).to.be.a('function');
-      expect(prompt.bindEvents).to.be.a('function');
+      expect(prompt.createNodeContent).to.be.a('function')
+      expect(prompt.bindEvents).to.be.a('function')
     })
     it('would prompt mount on document when instance is created', function () {
-      const PROMPT_WEEX_CLASS_NAME = '.weex-prompt';
-      const PROMPT_WEEX_MSG_CLASS_NAME = '.content-msg';
-      const OK_BUTTON_CLASS = '.btn-ok';
-      const CANCEL_BUTTON_CLASS = '.btn-cancel';
-      let $Prompt;
+      const PROMPT_WEEX_CLASS_NAME = '.weex-prompt'
+      const PROMPT_WEEX_MSG_CLASS_NAME = '.content-msg'
+      const OK_BUTTON_CLASS = '.btn-ok'
+      const CANCEL_BUTTON_CLASS = '.btn-cancel'
+      let $Prompt
       $Prompt = document.querySelector(PROMPT_WEEX_CLASS_NAME)
-      let messageShouldBe = $Prompt.querySelector(PROMPT_WEEX_MSG_CLASS_NAME).innerText
+      const messageShouldBe = $Prompt.querySelector(PROMPT_WEEX_MSG_CLASS_NAME).innerText
       let button = $Prompt.querySelector(OK_BUTTON_CLASS)
       expect(messageShouldBe, 'should contain Test message').to.be.equal(config.message)
-      let event = document.createEvent('HTMLEvents');
-      $Prompt.querySelector('input').value = inputMessage;
-      event.initEvent("click", false, true);
-      button.dispatchEvent(event);
+      let event = document.createEvent('HTMLEvents')
+      $Prompt.querySelector('input').value = inputMessage
+      event.initEvent('click', false, true)
+      button.dispatchEvent(event)
       $Prompt = document.querySelector(PROMPT_WEEX_CLASS_NAME)
-      expect($Prompt, 'element would unmount while ok button is clicked').to.be.null;
+      expect($Prompt, 'element would unmount while ok button is clicked').to.be.null
       expect(callbackResult, 'callback would return {result:string,data:string}').to.deep.equal({
         result: config.okTitle,
         data: inputMessage
-      });
-      //reopen prompt for test cancel button
+      })
+      //  reopen prompt for test cancel button
       prompt = new Prompt(config)
       $Prompt = document.querySelector(PROMPT_WEEX_CLASS_NAME)
       button = $Prompt.querySelector(CANCEL_BUTTON_CLASS)
-      event = document.createEvent('HTMLEvents');
-      $Prompt.querySelector('input').value = inputMessage;
-      event.initEvent("click", false, true);
-      button.dispatchEvent(event);
+      event = document.createEvent('HTMLEvents')
+      $Prompt.querySelector('input').value = inputMessage
+      event.initEvent('click', false, true)
+      button.dispatchEvent(event)
       $Prompt = document.querySelector(PROMPT_WEEX_CLASS_NAME)
-      expect($Prompt, 'element would unmount while ok button is clicked').to.be.null;
+      expect($Prompt, 'element would unmount while ok button is clicked').to.be.null
       expect(callbackResult, 'callback would return {result:string,data:string}').to.deep.equal({
         result: config.cancelTitle,
         data: inputMessage
-      });
+      })
     })
-  });
-});
+  })
+})

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/7202cabb/html5/test/render/vue/modules/websocket.js
----------------------------------------------------------------------
diff --git a/html5/test/render/vue/modules/websocket.js b/html5/test/render/vue/modules/websocket.js
index dc3441c..fa6f757 100644
--- a/html5/test/render/vue/modules/websocket.js
+++ b/html5/test/render/vue/modules/websocket.js
@@ -4,7 +4,7 @@
  * 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
+ * "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
@@ -16,100 +16,93 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+/*global WebSocket*/
 import websocket from '../../../../render/vue/modules/websocket/websocket'
-const TestUrl = 'ws://echo.websocket.org';
+const TestUrl = 'ws://echo.websocket.org'
 /** @test {webSocket module} */
-describe('webSocket module', function() {
-  after(function(done) {
-    const ws = new WebSocket(TestUrl);
-    ws.addEventListener('open', function() {
-      ws.send('shutdown');
-      done();
-    });
-  });
-  describe('extends Standard WebSocket API', function() {
-    context('should inherit', function() {
-      let ws = websocket.WebSocket(TestUrl);
-      it('methods', function() {
-        expect(websocket, 'should close method to be defined').to.have.property('close');
-        expect(websocket, 'should send method to be defined').to.have.property('send');
-      });
-      it('attributes', function() {
-        expect(websocket, 'should onerror to be defined').to.have.property('onerror');
-        expect(websocket, 'should onmessage to be defined').to.have.property('onmessage');
-        expect(websocket, 'should onopen to be defined').to.have.property('onopen');
-        expect(websocket, 'should onclose to be defined').to.have.property('onclose');
-        expect(ws, 'should binaryType to be defined').to.have.property('binaryType');
-        expect(ws, 'should bufferdAmount to be defined').to.have.property('bufferedAmount');
-        expect(ws, 'should extensions to be defined').to.have.property('extensions');
-        expect(ws, 'should protocol to be defined').to.have.property('protocol');
-        expect(ws, 'should readyState to be defined').to.have.property('readyState');
-        expect(ws, 'should url to be defined').to.have.property('url');
-      });
- 
-      it('constants', function() {
-        expect(websocket, 'should INSTANCE to be defined').to.have.property('INSTANCE');
-      });
-    });
- 
-    context('should forward native events', function() {
-      let ws;
-      this.timeout(8000)
-      beforeEach(function() {
-        ws = websocket.WebSocket(TestUrl);
-      });
- 
-      afterEach(function() {
-        websocket.close();
-      });
- 
-      it('open', function(done) {
-        websocket.onopen = function(){
-          done();
+describe('webSocket module', function () {
+  after(function (done) {
+    const ws = new WebSocket(TestUrl)
+    ws.addEventListener('open', function () {
+      ws.send('shutdown')
+      done()
+    })
+  })
+  describe('extends Standard WebSocket API', function () {
+    context('should inherit', function () {
+      const ws = websocket.WebSocket(TestUrl)
+      it('methods', function () {
+        expect(websocket, 'should close method to be defined').to.have.property('close')
+        expect(websocket, 'should send method to be defined').to.have.property('send')
+      })
+      it('attributes', function () {
+        expect(websocket, 'should onerror to be defined').to.have.property('onerror')
+        expect(websocket, 'should onmessage to be defined').to.have.property('onmessage')
+        expect(websocket, 'should onopen to be defined').to.have.property('onopen')
+        expect(websocket, 'should onclose to be defined').to.have.property('onclose')
+        expect(ws, 'should binaryType to be defined').to.have.property('binaryType')
+        expect(ws, 'should bufferdAmount to be defined').to.have.property('bufferedAmount')
+        expect(ws, 'should extensions to be defined').to.have.property('extensions')
+        expect(ws, 'should protocol to be defined').to.have.property('protocol')
+        expect(ws, 'should readyState to be defined').to.have.property('readyState')
+        expect(ws, 'should url to be defined').to.have.property('url')
+      })
+      it('constants', function () {
+        expect(websocket, 'should INSTANCE to be defined').to.have.property('INSTANCE')
+      })
+    })
+    context('should forward native events', function () {
+      let ws = null
+      beforeEach(function () {
+        ws = websocket.WebSocket(TestUrl)
+      })
+      afterEach(function () {
+        websocket.close()
+      })
+      it('open', function (done) {
+        websocket.onopen = function () {
+          done()
         }
-      });
-      it('close', function(done) {
-        let closed = false;
-        ws.onclose = function(){
+      })
+      it('close', function (done) {
+        let closed = false
+        ws.onclose = function () {
           if (!closed) {
-            done();
-            closed = true;
+            done()
+            closed = true
           }
         }
-        websocket.onopen = function(){
+        websocket.onopen = function () {
           websocket.close()
         }
-      });
- 
-      it('message', function(done) {
-        const message = 'Test';
-        websocket.onmessage = function(e){
-          expect(e.data).to.be.equal(message);
-          done();
+      })
+      it('message', function (done) {
+        const message = 'Test'
+        websocket.onmessage = function (e) {
+          expect(e.data).to.be.equal(message)
+          done()
         }
-        websocket.onopen = function(){
-          websocket.send(message);
+        websocket.onopen = function () {
+          websocket.send(message)
         }
-      });
-    });
-    describe('should ignore',function(){
-        it('protocol is undefined', function(done) {
-          let ws = websocket.WebSocket(TestUrl)
-          expect(websocket.INSTANCE).not.to.be.null;
-          done();
-        });
- 
-        it('url is undefined', function(done) {
-          let ws = websocket.WebSocket('')
-          expect(websocket.INSTANCE).to.be.null;
-          done();
-        });
-
-        it('both url and protocol is defined', function(done) {
-          let ws = websocket.WebSocket(TestUrl,'ws')
-          expect(websocket.INSTANCE).not.to.be.null;
-          done();
-        });
+      })
+    })
+    describe('should ignore', function () {
+      it('protocol is undefined', function (done) {
+        websocket.WebSocket(TestUrl)
+        expect(websocket.INSTANCE).not.to.be.null
+        done()
+      })
+      it('url is undefined', function (done) {
+        websocket.WebSocket('')
+        expect(websocket.INSTANCE).to.be.null
+        done()
+      })
+      it('both url and protocol is defined', function (done) {
+        websocket.WebSocket(TestUrl, 'ws')
+        expect(websocket.INSTANCE).not.to.be.null
+        done()
+      })
     })
-  });
-});
\ No newline at end of file
+  })
+})


Mime
View raw message