cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From audre...@apache.org
Subject cordova-plugin-test-framework git commit: CB-12895 : replaced jshint with eslint
Date Tue, 01 Aug 2017 16:40:16 GMT
Repository: cordova-plugin-test-framework
Updated Branches:
  refs/heads/master d0d3af99c -> 37acdf607


CB-12895 : replaced jshint with eslint


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/commit/37acdf60
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/tree/37acdf60
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/diff/37acdf60

Branch: refs/heads/master
Commit: 37acdf6074e05a27768e02ab892782f97fedee24
Parents: d0d3af9
Author: Audrey So <audreyso@apache.org>
Authored: Mon Jul 31 17:00:17 2017 -0700
Committer: Audrey So <audreyso@apache.org>
Committed: Mon Jul 31 17:09:13 2017 -0700

----------------------------------------------------------------------
 .eslintignore                |   2 +
 .eslintrc.yml                |  10 +
 package.json                 |  12 +-
 www/assets/jasmine-medic.js  | 212 +++++++-------
 www/assets/main-bootstrap.js |   6 +-
 www/jasmine_helpers.js       |  26 +-
 www/main.js                  | 564 +++++++++++++++++++-------------------
 www/medic.js                 |  39 ++-
 www/tests.js                 | 175 ++++++------
 9 files changed, 528 insertions(+), 518 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/.eslintignore
----------------------------------------------------------------------
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..85182f7
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+www/assets/jasmine-2.4.1
+www/assets/topcoat-0.7.5
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/.eslintrc.yml
----------------------------------------------------------------------
diff --git a/.eslintrc.yml b/.eslintrc.yml
new file mode 100644
index 0000000..0cccb8c
--- /dev/null
+++ b/.eslintrc.yml
@@ -0,0 +1,10 @@
+root: true
+extends: semistandard
+rules:
+  indent:
+    - error
+    - 4
+  camelcase: off
+  padded-blocks: off
+  operator-linebreak: off
+  no-throw-literal: off
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 44a7693..0c8a0df 100644
--- a/package.json
+++ b/package.json
@@ -19,12 +19,18 @@
     "ecosystem:cordova"
   ],
   "scripts": {
-    "test": "npm run jshint",
-    "jshint": "jshint www"
+    "test": "npm run eslint",
+    "eslint": "eslint www"
   },
   "author": "Apache Software Foundation",
   "license": "Apache-2.0",
   "devDependencies": {
-    "jshint": "^2.6.0"
+    "eslint": "^4.2.0",
+    "eslint-config-semistandard": "^11.0.0",
+    "eslint-config-standard": "^10.2.1",
+    "eslint-plugin-import": "^2.7.0",
+    "eslint-plugin-node": "^5.1.1",
+    "eslint-plugin-promise": "^3.5.0",
+    "eslint-plugin-standard": "^3.0.1"
   }
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/assets/jasmine-medic.js
----------------------------------------------------------------------
diff --git a/www/assets/jasmine-medic.js b/www/assets/jasmine-medic.js
index e2738e3..8cd69ce 100644
--- a/www/assets/jasmine-medic.js
+++ b/www/assets/jasmine-medic.js
@@ -20,117 +20,117 @@
 */
 
 /* global device */
+/* eslint no-undef : 0 */
 
-jasmineRequire.medic = function(j$) {
-  j$.MedicReporter = jasmineRequire.MedicReporter(j$);
+jasmineRequire.medic = function (j$) {
+    j$.MedicReporter = jasmineRequire.MedicReporter(j$);
 };
 
-jasmineRequire.MedicReporter = function(j$) {
-  var noopTimer = {
-    start: function() {},
-    elapsed: function() { return 0; }
-  };
-
-  var platformMap = {
-    'ipod touch':'ios',
-    'iphone':'ios'
-  };
-
-  function MedicReporter(options) {
-    var logoptions = options.log || { logurl: 'http://127.0.0.1:5984/' }, // TODO: http://localhost:6800
-    timer = options.timer || noopTimer,
-    results = [],
-    specsExecuted = 0,
-    failureCount = 0,
-    pendingSpecCount = 0;
-
-
-    var serverurl = logoptions.logurl;
-
-    this.initialize = function() {
-    };
-
-    var totalSpecsDefined;
-    this.jasmineStarted = function(options) {
-      totalSpecsDefined = options.totalSpecsDefined || 0;
-      timer.start();
-    };
-
-    this.suiteStarted = function(result) {
-    };
-
-    this.suiteDone = function(result) {
-
-    };
-
-    this.specStarted = function(result) {
-       console.log('>>>>> Spec started: ' + result.description);
-    };
-
-    this.specDone = function(result) {
-      if (result.status != "disabled") {
-        specsExecuted++;
-      }
-      if (result.status == "failed") {
-        failureCount++;
-        results.push(result);
-      }
-      if (result.status == "pending") {
-        pendingSpecCount++;
-      }
-       console.log('>>>>> Spec completed: ' + result.description);
-    };
-
-    var buildResults = function(){
-      var json ={specs:specsExecuted, failures:failureCount, results: results};
-      return json;
-    };
-
-    this.jasmineDone = function() {
-      var p = 'Desktop';
-      var devmodel='none';
-      var version = cordova.version;
-      if(typeof device != 'undefined') {
-        p = device.platform.toLowerCase();
-        devmodel=device.model || device.name;
-        version = device.version.toLowerCase();
-      }
-
-      this.postTests({
-          mobilespec:buildResults(),
-          platform:(platformMap.hasOwnProperty(p) ? platformMap[p] : p),
-          version:version,
-          sha: options.sha,
-          timestamp:Math.round(Math.floor((new Date()).getTime() / 1000)),
-          model:devmodel
-          });
-
+jasmineRequire.MedicReporter = function (j$) {
+    var noopTimer = {
+        start: function () {},
+        elapsed: function () { return 0; }
     };
 
-    this.postTests = function(json) {
-      console.log('posting tests');
-
-      var xhr = new XMLHttpRequest();
-      var doc_id = [options.sha, json.version, json.model].map(encodeURIComponent).join('__');
-      var doc_url = serverurl + '/mobilespec_results/' + doc_id;
-      xhr.open("PUT", doc_url, true);
-      xhr.onload = function (e) {
-        if (xhr.readyState === 4) {
-          if (xhr.status === 200) {
-            console.log("Posting results to CouchDB succeeded: " + xhr.responseText);
-          } else {
-            console.log("Error posting to CouchDB: " + xhr.statusText);
-          }
-        }
-      };
-      xhr.onerror = function (e) {
-        console.log("Error posting to CouchDB: " + xhr.statusText);
-      };
-      xhr.setRequestHeader("Content-Type","application/json");
-      xhr.send(JSON.stringify(json));
+    var platformMap = {
+        'ipod touch': 'ios',
+        'iphone': 'ios'
     };
-    return this;
-  }
 
-  return MedicReporter;
+    function MedicReporter (options) {
+        var logoptions = options.log || { logurl: 'http://127.0.0.1:5984/' }; // TODO: http://localhost:6800
+        var timer = options.timer || noopTimer;
+        var results = [];
+        var specsExecuted = 0;
+        var failureCount = 0; // eslint-disable-line no-unused-vars
+        var pendingSpecCount = 0; // eslint-disable-line no-unused-vars
+
+        var serverurl = logoptions.logurl;
+
+        this.initialize = function () {
+        };
+
+        var totalSpecsDefined; // eslint-disable-line no-unused-vars
+        this.jasmineStarted = function (options) {
+            totalSpecsDefined = options.totalSpecsDefined || 0;
+            timer.start();
+        };
+
+        this.suiteStarted = function (result) {
+        };
+
+        this.suiteDone = function (result) {
+
+        };
+
+        this.specStarted = function (result) {
+            console.log('>>>>> Spec started: ' + result.description);
+        };
+
+        this.specDone = function (result) {
+            if (result.status !== 'disabled') {
+                specsExecuted++;
+            }
+            if (result.status === 'failed') {
+                failureCount++;
+                results.push(result);
+            }
+            if (result.status === 'pending') {
+                pendingSpecCount++;
+            }
+            console.log('>>>>> Spec completed: ' + result.description);
+        };
+
+        var buildResults = function () {
+            var json = {specs: specsExecuted, failures: failureCount, results: results};
+            return json;
+        };
+
+        this.jasmineDone = function () {
+            var p = 'Desktop';
+            var devmodel = 'none';
+            var version = cordova.version;
+            if (typeof device !== 'undefined') {
+                p = device.platform.toLowerCase();
+                devmodel = device.model || device.name;
+                version = device.version.toLowerCase();
+            }
+
+            this.postTests({
+                mobilespec: buildResults(),
+                platform: (platformMap.hasOwnProperty(p) ? platformMap[p] : p),
+                version: version,
+                sha: options.sha,
+                timestamp: Math.round(Math.floor((new Date()).getTime() / 1000)),
+                model: devmodel
+            });
+
+        };
+
+        this.postTests = function (json) {
+            console.log('posting tests');
+
+            var xhr = new XMLHttpRequest();
+            var doc_id = [options.sha, json.version, json.model].map(encodeURIComponent).join('__');
+            var doc_url = serverurl + '/mobilespec_results/' + doc_id;
+            xhr.open('PUT', doc_url, true);
+            xhr.onload = function (e) {
+                if (xhr.readyState === 4) {
+                    if (xhr.status === 200) {
+                        console.log('Posting results to CouchDB succeeded: ' + xhr.responseText);
+                    } else {
+                        console.log('Error posting to CouchDB: ' + xhr.statusText);
+                    }
+                }
+            };
+            xhr.onerror = function (e) {
+                console.log('Error posting to CouchDB: ' + xhr.statusText);
+            };
+            xhr.setRequestHeader('Content-Type', 'application/json');
+            xhr.send(JSON.stringify(json));
+        };
+        return this;
+    }
+
+    return MedicReporter;
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/assets/main-bootstrap.js
----------------------------------------------------------------------
diff --git a/www/assets/main-bootstrap.js b/www/assets/main-bootstrap.js
index 58624b7..90b0d88 100644
--- a/www/assets/main-bootstrap.js
+++ b/www/assets/main-bootstrap.js
@@ -19,8 +19,8 @@
  *
 */
 
-document.addEventListener("deviceready", function() {
-  'use strict';
+document.addEventListener('deviceready', function () {
+    'use strict';
 
-  cordova.require('cordova-plugin-test-framework.main').init();
+    cordova.require('cordova-plugin-test-framework.main').init(); // eslint-disable-line
no-undef
 });

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/jasmine_helpers.js
----------------------------------------------------------------------
diff --git a/www/jasmine_helpers.js b/www/jasmine_helpers.js
index fe9e06d..53f7bbe 100644
--- a/www/jasmine_helpers.js
+++ b/www/jasmine_helpers.js
@@ -19,10 +19,10 @@
  *
 */
 
-/* jshint -W097 */
+/* eslint no-undef : 0 */
 'use strict';
 
-exports.setUpJasmine = function() {
+exports.setUpJasmine = function () {
     // Set up jasmine
     var jasmine = jasmineRequire.core(jasmineRequire);
     jasmineRequire.html(jasmine);
@@ -38,31 +38,31 @@ exports.setUpJasmine = function() {
     addJasmineReporters(jasmineInterface, jasmineEnv);
 
     // Add Spec Filter
-    jasmineEnv.specFilter = function(spec) {
-        //console.log(spec.getFullName());
+    jasmineEnv.specFilter = function (spec) {
+        // console.log(spec.getFullName());
         return true;
     };
 
     // Jasmine 2.2.0 moved this symbol, so we add a shim here.
-    jasmine.Expectation.addMatchers = jasmine.Expectation.addMatchers || function() {
+    jasmine.Expectation.addMatchers = jasmine.Expectation.addMatchers || function () {
         return jasmine.addMatchers.apply(this, arguments);
     };
 
     return jasmineInterface;
 };
 
-function addJasmineReporters(jasmineInterface, jasmineEnv) {
+function addJasmineReporters (jasmineInterface, jasmineEnv) {
     jasmineInterface.jsApiReporter = new jasmineInterface.jasmine.JsApiReporter({ timer:
new jasmineInterface.jasmine.Timer() });
     jasmineEnv.addReporter(jasmineInterface.jsApiReporter);
 
     jasmineInterface.htmlReporter = new jasmineInterface.jasmine.HtmlReporter({
         env: jasmineEnv,
-        queryString: function() { return null; },
-        onRaiseExceptionsClick: function() { },
-        onThrowExpectationsClick: function() { },
-        getContainer: function() { return document.getElementById('content'); },
-        createElement: function() { return document.createElement.apply(document, arguments);
},
-        createTextNode: function() { return document.createTextNode.apply(document, arguments);
},
+        queryString: function () { return null; },
+        onRaiseExceptionsClick: function () { },
+        onThrowExpectationsClick: function () { },
+        getContainer: function () { return document.getElementById('content'); },
+        createElement: function () { return document.createElement.apply(document, arguments);
},
+        createTextNode: function () { return document.createTextNode.apply(document, arguments);
},
         timer: new jasmineInterface.jasmine.Timer()
     });
     jasmineInterface.htmlReporter.initialize();
@@ -80,5 +80,5 @@ function addJasmineReporters(jasmineInterface, jasmineEnv) {
         jasmineInterface.MedicReporter.initialize();
         jasmineEnv.addReporter(jasmineInterface.MedicReporter);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/main.js
----------------------------------------------------------------------
diff --git a/www/main.js b/www/main.js
index 7e17efd..56d0897 100644
--- a/www/main.js
+++ b/www/main.js
@@ -20,80 +20,80 @@
 */
 
 /* global WinJS */
-/* jshint -W097 */
+/* eslint no-undef : 0 */
 'use strict';
 
-var LOG_HEADER_HEIGHT = 20,
-    CONTENT_TOP_OFFSET = 30;
+var LOG_HEADER_HEIGHT = 20;
+var CONTENT_TOP_OFFSET = 30;
 
-var isWin = cordova.platformId === "windows",
-    isWP8 = cordova.platformId === "windowsphone";
+var isWin = cordova.platformId === 'windows';
+var isWP8 = cordova.platformId === 'windowsphone';
 
 /******************************************************************************/
 
-function getMode(callback) {
-  var mode = localStorage.getItem('cdvtests-mode') || 'main';
-  callback(mode);
+function getMode (callback) {
+    var mode = localStorage.getItem('cdvtests-mode') || 'main';
+    callback(mode);
 }
 
-function setMode(mode) {
-  var handlers = {
-    'main': runMain,
-    'auto': runAutoTests,
-    'manual': runManualTests
-  };
-  if (!handlers.hasOwnProperty(mode)) {
-    console.error("Unsupported mode: " + mode);
-    console.error("Defaulting to 'main'");
-    mode = 'main';
-  }
-
-  localStorage.setItem('cdvtests-mode', mode);
-  clearContent();
-
-  handlers[mode]();
+function setMode (mode) {
+    var handlers = {
+        'main': runMain,
+        'auto': runAutoTests,
+        'manual': runManualTests
+    };
+    if (!handlers.hasOwnProperty(mode)) {
+        console.error('Unsupported mode: ' + mode);
+        console.error("Defaulting to 'main'");
+        mode = 'main';
+    }
+
+    localStorage.setItem('cdvtests-mode', mode);
+    clearContent();
+
+    handlers[mode]();
 }
 
 /******************************************************************************/
 
-function clearContent() {
-  var content = document.getElementById('content');
-  content.innerHTML = '';
-  var log = document.getElementById('log--content');
-  log.innerHTML = '';
-  var buttons = document.getElementById('buttons');
-  buttons.innerHTML = '';
+function clearContent () {
+    var content = document.getElementById('content');
+    content.innerHTML = '';
+    var log = document.getElementById('log--content');
+    log.innerHTML = '';
+    var buttons = document.getElementById('buttons');
+    buttons.innerHTML = '';
 
-  setLogVisibility(false);
+    setLogVisibility(false);
 }
 
 /******************************************************************************/
 
-function setTitle(title) {
-  var el = document.getElementById('title');
-  el.textContent = title;
+function setTitle (title) {
+    var el = document.getElementById('title');
+    el.textContent = title;
 }
 
 /******************************************************************************/
 
-function setLogVisibility(visible) {
+function setLogVisibility (visible) {
     if (visible) {
         document.querySelector('body').classList.add('expanded-log');
 
         if (isWin || isWP8) {
             var h = document.querySelector('body').offsetHeight;
 
-            document.getElementById('middle').style.height = (h * 0.6 - LOG_HEADER_HEIGHT
- CONTENT_TOP_OFFSET) + "px";
-            document.getElementById('middle').style.marginBottom = (h * 0.4) + "px";
-            document.getElementById('middle').style.paddingBottom = (h * 0.4) + "px";
+            document.getElementById('middle').style.height = (h * 0.6 - LOG_HEADER_HEIGHT
- CONTENT_TOP_OFFSET) + 'px';
+            document.getElementById('middle').style.marginBottom = (h * 0.4) + 'px';
+            document.getElementById('middle').style.paddingBottom = (h * 0.4) + 'px';
         }
     } else {
         document.querySelector('body').classList.remove('expanded-log');
 
         if (isWin || isWP8) {
-            document.getElementById('middle').style.height = "";
-            document.getElementById('middle').style.marginBottom = "";
-            document.getElementById('middle').style.paddingBottom = "";
+            document.getElementById('middle').style.height = '';
+            document.getElementById('middle').style.marginBottom = '';
+            document.getElementById('middle').style.paddingBottom = '';
         }
     }
 }
@@ -105,339 +105,339 @@ window.onresize = function (event) {
     }
 };
 
-function getLogVisibility() {
-  var e = document.querySelector('body');
-  return e.classList.contains('expanded-log');
+function getLogVisibility () {
+    var e = document.querySelector('body');
+    return e.classList.contains('expanded-log');
 }
 
-function toggleLogVisibility() {
-  if (getLogVisibility()) {
-    setLogVisibility(false);
-  } else {
-    setLogVisibility(true);
-  }
+function toggleLogVisibility () {
+    if (getLogVisibility()) {
+        setLogVisibility(false);
+    } else {
+        setLogVisibility(true);
+    }
 }
 
 /******************************************************************************/
 
-function attachEvents() {
-  document.getElementById('log--title').addEventListener('click', toggleLogVisibility);
+function attachEvents () {
+    document.getElementById('log--title').addEventListener('click', toggleLogVisibility);
 }
 
 /******************************************************************************/
 
 var origConsole = window.console;
 
-exports.wrapConsole = function() {
-  function appendToOnscreenLog(type, args) {
-    var el = document.getElementById('log--content');
-    var div = document.createElement('div');
-    div.classList.add('log--content--line');
-    div.classList.add('log--content--line--' + type);
-    div.textContent = Array.prototype.slice.apply(args).map(function(arg) {
-        return (typeof arg === 'string') ? arg : JSON.stringify(arg);
-      }).join(' ');
-    el.appendChild(div);
-    // scroll to bottom
-    el.scrollTop = el.scrollHeight;
-  }
-
-  function createCustomLogger(type) {
-    return function() {
-      origConsole[type].apply(origConsole, arguments);
-      appendToOnscreenLog(type, arguments);
-      setLogVisibility(true);
-    };
-  }
+exports.wrapConsole = function () {
+    function appendToOnscreenLog (type, args) {
+        var el = document.getElementById('log--content');
+        var div = document.createElement('div');
+        div.classList.add('log--content--line');
+        div.classList.add('log--content--line--' + type);
+        div.textContent = Array.prototype.slice.apply(args).map(function (arg) {
+            return (typeof arg === 'string') ? arg : JSON.stringify(arg);
+        }).join(' ');
+        el.appendChild(div);
+        // scroll to bottom
+        el.scrollTop = el.scrollHeight;
+    }
+
+    function createCustomLogger (type) {
+        return function () {
+            origConsole[type].apply(origConsole, arguments);
+            appendToOnscreenLog(type, arguments);
+            setLogVisibility(true);
+        };
+    }
 
-  window.console = {
-    log: createCustomLogger('log'),
-    warn: createCustomLogger('warn'),
-    error: createCustomLogger('error'),
-  };
+    window.console = {
+        log: createCustomLogger('log'),
+        warn: createCustomLogger('warn'),
+        error: createCustomLogger('error')
+    };
 };
 
-exports.unwrapConsole = function() {
-  window.console = origConsole;
+exports.unwrapConsole = function () {
+    window.console = origConsole;
 };
 
 /******************************************************************************/
 
-function createActionButton(title, callback, appendTo) {
-  appendTo = appendTo ? appendTo : 'buttons';
-  var buttons = document.getElementById(appendTo);
-  var div = document.createElement('div');
-  var button = document.createElement('a');
-  button.textContent = title;
-  button.onclick = function(e) {
-    e.preventDefault();
-    callback();
-  };
-  button.classList.add('topcoat-button');
-  div.appendChild(button);
-  buttons.appendChild(div);
+function createActionButton (title, callback, appendTo) {
+    appendTo = appendTo || 'buttons';
+    var buttons = document.getElementById(appendTo);
+    var div = document.createElement('div');
+    var button = document.createElement('a');
+    button.textContent = title;
+    button.onclick = function (e) {
+        e.preventDefault();
+        callback();
+    };
+    button.classList.add('topcoat-button');
+    div.appendChild(button);
+    buttons.appendChild(div);
 }
 
 /******************************************************************************/
 
-function setupAutoTestsEnablers(cdvtests) {
-  var enablerList = createEnablerList();
+function setupAutoTestsEnablers (cdvtests) {
+    var enablerList = createEnablerList();
 
-  // Iterate over all the registered test modules
-  iterateAutoTests(cdvtests, function(api, testModule) {
-    // For "standard" plugins remove the common/repetitive bits of
-    // the api key, for use as the title.  For third-party plugins, the full
-    // api will be used as the title
-    var title = api.replace(/org\.apache\.cordova\./i, '').replace(/\.tests.tests/i, '');
+    // Iterate over all the registered test modules
+    iterateAutoTests(cdvtests, function (api, testModule) {
+        // For "standard" plugins remove the common/repetitive bits of
+        // the api key, for use as the title.  For third-party plugins, the full
+        // api will be used as the title
+        var title = api.replace(/org\.apache\.cordova\./i, '').replace(/\.tests.tests/i,
'');
 
-    createEnablerCheckbox(api, title, testModule.getEnabled(), enablerList.id, toggleTestHandler);
-  });
+        createEnablerCheckbox(api, title, testModule.getEnabled(), enablerList.id, toggleTestHandler);
+    });
 
-  updateEnabledTestCount();
+    updateEnabledTestCount();
 }
 
 /******************************************************************************/
 
-function createEnablerList() {
-  var buttons = document.getElementById('buttons');
-
-  var enablerContainer = document.createElement('div');
-  enablerContainer.id = 'test-enablers-container';
-
-  // Create header to show count of enabled/total tests
-  var header = document.createElement('h3');
-  header.id = 'tests-enabled';
-
-  // Create widget to show/hide list
-  var expander = document.createElement('span');
-  expander.id = 'test-expander';
-  expander.innerText = 'Show/hide tests to be run';
-  expander.onclick = toggleEnablerVisibility;
-
-  // Create list to contain checkboxes for each test
-  var enablerList = document.createElement('div');
-  enablerList.id = "test-list";
-
-  // Create select/deselect all buttons (in button bar)
-  var checkButtonBar = document.createElement('ul');
-  checkButtonBar.classList.add('topcoat-button-bar');
-
-  function createSelectToggleButton(title, selected) {
-    var barItem = document.createElement('li');
-    barItem.classList.add('topcoat-button-bar__item');
-
-    var link = document.createElement('a');
-    link.classList.add('topcoat-button-bar__button');
-    link.innerText = title;
-    link.href = null;
-    link.onclick = function(e) {
-      e.preventDefault();
-      toggleSelected(enablerList.id, selected);
-      return false;
-    };
-
-    barItem.appendChild(link);
-    checkButtonBar.appendChild(barItem);
-  }
-  createSelectToggleButton('Check all', true);
-  createSelectToggleButton('Uncheck all', false);
-  enablerList.appendChild(checkButtonBar);
+function createEnablerList () {
+    var buttons = document.getElementById('buttons');
+
+    var enablerContainer = document.createElement('div');
+    enablerContainer.id = 'test-enablers-container';
+
+    // Create header to show count of enabled/total tests
+    var header = document.createElement('h3');
+    header.id = 'tests-enabled';
+
+    // Create widget to show/hide list
+    var expander = document.createElement('span');
+    expander.id = 'test-expander';
+    expander.innerText = 'Show/hide tests to be run';
+    expander.onclick = toggleEnablerVisibility;
+
+    // Create list to contain checkboxes for each test
+    var enablerList = document.createElement('div');
+    enablerList.id = 'test-list';
+
+    // Create select/deselect all buttons (in button bar)
+    var checkButtonBar = document.createElement('ul');
+    checkButtonBar.classList.add('topcoat-button-bar');
+
+    function createSelectToggleButton (title, selected) {
+        var barItem = document.createElement('li');
+        barItem.classList.add('topcoat-button-bar__item');
+
+        var link = document.createElement('a');
+        link.classList.add('topcoat-button-bar__button');
+        link.innerText = title;
+        link.href = null;
+        link.onclick = function (e) {
+            e.preventDefault();
+            toggleSelected(enablerList.id, selected);
+            return false;
+        };
+
+        barItem.appendChild(link);
+        checkButtonBar.appendChild(barItem);
+    }
+    createSelectToggleButton('Check all', true);
+    createSelectToggleButton('Uncheck all', false);
+    enablerList.appendChild(checkButtonBar);
 
-  enablerContainer.appendChild(header);
-  enablerContainer.appendChild(expander);
-  enablerContainer.appendChild(enablerList);
+    enablerContainer.appendChild(header);
+    enablerContainer.appendChild(expander);
+    enablerContainer.appendChild(enablerList);
 
-  buttons.appendChild(enablerContainer);
+    buttons.appendChild(enablerContainer);
 
-  return enablerList;
+    return enablerList;
 }
 
 /******************************************************************************/
 
-function updateEnabledTestCount() {
-  var enabledLabel = document.getElementById('tests-enabled');
-
-  // Determine how many tests are currently enabled
-  var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
-  var total = 0;
-  var enabled = 0;
-  iterateAutoTests(cdvtests, function(api, testModule) {
-    total++;
-    if (testModule.getEnabled()) {
-      enabled++;
-    }
-  });
+function updateEnabledTestCount () {
+    var enabledLabel = document.getElementById('tests-enabled');
+
+    // Determine how many tests are currently enabled
+    var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
+    var total = 0;
+    var enabled = 0;
+    iterateAutoTests(cdvtests, function (api, testModule) {
+        total++;
+        if (testModule.getEnabled()) {
+            enabled++;
+        }
+    });
 
-  if (enabled == total) {
-    enabledLabel.innerText = 'Running All Tests.';
-  } else {
-    enabledLabel.innerText = 'Running ' + enabled + ' of ' + total + ' Tests.';
-  }
+    if (enabled === total) {
+        enabledLabel.innerText = 'Running All Tests.';
+    } else {
+        enabledLabel.innerText = 'Running ' + enabled + ' of ' + total + ' Tests.';
+    }
 }
 
 /******************************************************************************/
 
-function toggleSelected(containerId, newCheckedValue) {
-  [].forEach.call(document.getElementById(containerId).getElementsByTagName('input'), function(input)
{
-    if (input.type !== 'checkbox') return;
-    input.checked = newCheckedValue;
-    toggleTestEnabled(input);
-  });
-  updateEnabledTestCount();
+function toggleSelected (containerId, newCheckedValue) {
+    [].forEach.call(document.getElementById(containerId).getElementsByTagName('input'), function
(input) {
+        if (input.type !== 'checkbox') return;
+        input.checked = newCheckedValue;
+        toggleTestEnabled(input);
+    });
+    updateEnabledTestCount();
 }
 
 /******************************************************************************/
 
-function toggleEnablerVisibility() {
-  var enablerList = document.getElementById('test-list');
-  if (enablerList.classList.contains('expanded')) {
-    enablerList.classList.remove('expanded');
-  } else {
-    enablerList.classList.add('expanded');
-  }
+function toggleEnablerVisibility () {
+    var enablerList = document.getElementById('test-list');
+    if (enablerList.classList.contains('expanded')) {
+        enablerList.classList.remove('expanded');
+    } else {
+        enablerList.classList.add('expanded');
+    }
 }
 
 /******************************************************************************/
 
-function createEnablerCheckbox(api, title, isEnabled, appendTo, callback) {
-  var container = document.getElementById(appendTo);
+function createEnablerCheckbox (api, title, isEnabled, appendTo, callback) {
+    var container = document.getElementById(appendTo);
 
-  var label = document.createElement('label');
-  label.classList.add('topcoat-checkbox');
+    var label = document.createElement('label');
+    label.classList.add('topcoat-checkbox');
 
-  var checkbox = document.createElement('input');
-  checkbox.type = "checkbox";
-  checkbox.value = api;
-  checkbox.checked = isEnabled;
-  label.htmlFor = checkbox.id = 'enable_' + api;
+    var checkbox = document.createElement('input');
+    checkbox.type = 'checkbox';
+    checkbox.value = api;
+    checkbox.checked = isEnabled;
+    label.htmlFor = checkbox.id = 'enable_' + api;
 
-  checkbox.onchange = function(e) {
-    e.preventDefault();
-    callback(e);
-  };
+    checkbox.onchange = function (e) {
+        e.preventDefault();
+        callback(e);
+    };
 
-  var div = document.createElement('div');
-  div.classList.add('topcoat-checkbox__checkmark');
+    var div = document.createElement('div');
+    div.classList.add('topcoat-checkbox__checkmark');
 
-  var text = document.createElement('span');
-  text.innerText = title;
+    var text = document.createElement('span');
+    text.innerText = title;
 
-  label.appendChild(checkbox);
-  label.appendChild(div);
-  label.appendChild(text);
+    label.appendChild(checkbox);
+    label.appendChild(div);
+    label.appendChild(text);
 
-  container.appendChild(label);
+    container.appendChild(label);
 }
 
 /******************************************************************************/
 
-function toggleTestHandler(event) {
-  var checkbox = event.target;
+function toggleTestHandler (event) {
+    var checkbox = event.target;
 
-  toggleTestEnabled(checkbox);
-  updateEnabledTestCount();
+    toggleTestEnabled(checkbox);
+    updateEnabledTestCount();
 }
 
 /******************************************************************************/
 
-function toggleTestEnabled(checkbox) {
-  var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
-  cdvtests.tests[checkbox.value].setEnabled(checkbox.checked);
+function toggleTestEnabled (checkbox) {
+    var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
+    cdvtests.tests[checkbox.value].setEnabled(checkbox.checked);
 }
 
 /******************************************************************************/
 
-function iterateAutoTests(cdvtests, callback) {
-  Object.keys(cdvtests.tests).forEach(function(api) {
-    var testModule = cdvtests.tests[api];
-    if (!testModule.hasOwnProperty('defineAutoTests')) {
-      return;
-    }
-    callback(api, testModule);
-  });
+function iterateAutoTests (cdvtests, callback) {
+    Object.keys(cdvtests.tests).forEach(function (api) {
+        var testModule = cdvtests.tests[api];
+        if (!testModule.hasOwnProperty('defineAutoTests')) {
+            return;
+        }
+        callback(api, testModule);
+    });
 }
 
 /******************************************************************************/
 
-function runAutoTests() {
-  setTitle('Auto Tests');
+function runAutoTests () {
+    setTitle('Auto Tests');
 
-  createActionButton('Run', setMode.bind(null, 'auto'));
-  createActionButton('Reset App', location.reload.bind(location));
-  createActionButton('Back', setMode.bind(null, 'main'));
+    createActionButton('Run', setMode.bind(null, 'auto'));
+    createActionButton('Reset App', location.reload.bind(location));
+    createActionButton('Back', setMode.bind(null, 'main'));
 
-  var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
-  cdvtests.init();
-  setupAutoTestsEnablers(cdvtests);
+    var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
+    cdvtests.init();
+    setupAutoTestsEnablers(cdvtests);
 
-  cdvtests.defineAutoTests();
+    cdvtests.defineAutoTests();
 
-  // Run the tests!
-  var jasmineEnv = window.jasmine.getEnv();
+    // Run the tests!
+    var jasmineEnv = window.jasmine.getEnv();
 
-  jasmineEnv.execute();
+    jasmineEnv.execute();
 }
 
 /******************************************************************************/
 
-function runManualTests() {
-  setTitle('Manual Tests');
-
-  createActionButton('Reset App', location.reload.bind(location));
-  createActionButton('Back', setMode.bind(null, 'main'));
+function runManualTests () {
+    setTitle('Manual Tests');
 
-  var contentEl = document.getElementById('content');
-  var beforeEach = function(title) {
-    clearContent();
-    setTitle(title || 'Manual Tests');
     createActionButton('Reset App', location.reload.bind(location));
-    createActionButton('Back', setMode.bind(null, 'manual'));
-  };
-  var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
-  cdvtests.defineManualTests(contentEl, beforeEach, createActionButton);
+    createActionButton('Back', setMode.bind(null, 'main'));
+
+    var contentEl = document.getElementById('content');
+    var beforeEach = function (title) {
+        clearContent();
+        setTitle(title || 'Manual Tests');
+        createActionButton('Reset App', location.reload.bind(location));
+        createActionButton('Back', setMode.bind(null, 'manual'));
+    };
+    var cdvtests = cordova.require('cordova-plugin-test-framework.cdvtests');
+    cdvtests.defineManualTests(contentEl, beforeEach, createActionButton);
 }
 
 /******************************************************************************/
 
-function runMain() {
-  setTitle('Apache Cordova Plugin Tests');
-
-  createActionButton('Auto Tests', setMode.bind(null, 'auto'));
-  createActionButton('Manual Tests', setMode.bind(null, 'manual'));
-  createActionButton('Reset App', location.reload.bind(location));
-  if (/showBack/.exec(location.hash)) {
-      createActionButton('Back', function() {
-          history.go(-1);
-      });
-  }
-
-  if (isWin && typeof WinJS !== 'undefined') {
-    var app = WinJS.Application;
-    app.addEventListener("error", function (err) {
-        // We do not want an unhandled exception to crash the test app
-        // Returning true marks it as being handled
-        return true;
-      });
-  }
+function runMain () {
+    setTitle('Apache Cordova Plugin Tests');
+
+    createActionButton('Auto Tests', setMode.bind(null, 'auto'));
+    createActionButton('Manual Tests', setMode.bind(null, 'manual'));
+    createActionButton('Reset App', location.reload.bind(location));
+    if (/showBack/.exec(location.hash)) {
+        createActionButton('Back', function () {
+            history.go(-1);
+        });
+    }
+
+    if (isWin && typeof WinJS !== 'undefined') {
+        var app = WinJS.Application;
+        app.addEventListener('error', function (err) { // eslint-disable-line handle-callback-err
+            // We do not want an unhandled exception to crash the test app
+            // Returning true marks it as being handled
+            return true;
+        });
+    }
 }
 
 /******************************************************************************/
 
-exports.init = function() {
-  // TODO: have a way to opt-out of console wrapping in case line numbers are important.
-  // ...Or find a custom way to print line numbers using stack or something.
-  // make sure to always wrap when using medic.
-  attachEvents();
-  exports.wrapConsole();
-
-  var medic = require('cordova-plugin-test-framework.medic');
-  medic.load(function() {
-    if (medic.enabled) {
-      setMode('auto');
-    } else {
-      getMode(setMode);
-    }
-  });
+exports.init = function () {
+    // TODO: have a way to opt-out of console wrapping in case line numbers are important.
+    // ...Or find a custom way to print line numbers using stack or something.
+    // make sure to always wrap when using medic.
+    attachEvents();
+    exports.wrapConsole();
+
+    var medic = require('cordova-plugin-test-framework.medic');
+    medic.load(function () {
+        if (medic.enabled) {
+            setMode('auto');
+        } else {
+            getMode(setMode);
+        }
+    });
 };
 
 /******************************************************************************/

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/medic.js
----------------------------------------------------------------------
diff --git a/www/medic.js b/www/medic.js
index f656bc7..89141e6 100644
--- a/www/medic.js
+++ b/www/medic.js
@@ -19,7 +19,6 @@
  *
 */
 
-/* jshint -W097 */
 'use strict';
 
 exports.logurl = 'http://127.0.0.1:7800';
@@ -27,28 +26,28 @@ exports.logurl = 'http://127.0.0.1:7800';
 exports.enabled = false;
 
 exports.load = function (callback) {
-  var cfg = null;
+    var cfg = null;
 
-  try {
+    try {
     // attempt to synchronously load medic config
-    var xhr = new XMLHttpRequest();
-    xhr.open("GET", "../medic.json", false);
-    xhr.send(null);
-    cfg = JSON.parse(xhr.responseText);
-  } catch (ex) { }
+        var xhr = new XMLHttpRequest(); // eslint-disable-line no-undef
+        xhr.open('GET', '../medic.json', false);
+        xhr.send(null);
+        cfg = JSON.parse(xhr.responseText);
+    } catch (ex) { }
 
-  // config is available
-  if (cfg) {
-    exports.logurl = cfg.couchdb || cfg.logurl;
-    exports.sha = cfg.sha;
-    exports.enabled = true;
-    console.log('Loaded Medic Config: logurl=' + exports.logurl);
-  } else {
+    // config is available
+    if (cfg) {
+        exports.logurl = cfg.couchdb || cfg.logurl;
+        exports.sha = cfg.sha;
+        exports.enabled = true;
+        console.log('Loaded Medic Config: logurl=' + exports.logurl);
+    } else {
     // config does not exist
-    console.log('Did not find medic config file');
-  }
+        console.log('Did not find medic config file');
+    }
 
-  setTimeout(function () {
-      callback();
-  }, 0);
+    setTimeout(function () {
+        callback();
+    }, 0);
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework/blob/37acdf60/www/tests.js
----------------------------------------------------------------------
diff --git a/www/tests.js b/www/tests.js
index cea8898..655c108 100644
--- a/www/tests.js
+++ b/www/tests.js
@@ -19,117 +19,110 @@
  *
 */
 
-/* jshint jasmine: true */
-/* jshint -W097 */
 'use strict';
 
 exports.tests = Object.create(null);
 
-function TestModule(api) {
-  var name = api;
-  var enabled = true;
-
-  var enabledPref = localStorage.getItem('cordova-tests-enabled-' + name);
-  if (enabledPref)
-  {
-    enabled = (enabledPref == true.toString());
-  }
-  
-  this.getEnabled = function () {
-    return enabled;
-  };
-  
-  this.setEnabled = function (isEnabled) {
-    enabled = isEnabled;
-    localStorage.setItem('cordova-tests-enabled-' + name, enabled);
-  };
+function TestModule (api) {
+    var name = api;
+    var enabled = true;
+
+    var enabledPref = localStorage.getItem('cordova-tests-enabled-' + name); // eslint-disable-line
no-undef
+    if (enabledPref) {
+        enabled = (enabledPref === true.toString());
+    }
+
+    this.getEnabled = function () {
+        return enabled;
+    };
+
+    this.setEnabled = function (isEnabled) {
+        enabled = isEnabled;
+        localStorage.setItem('cordova-tests-enabled-' + name, enabled); // eslint-disable-line
no-undef
+    };
 }
 
-function getTestsObject(api) {
-  exports.tests[api] = exports.tests[api] || new TestModule(api);
-  return exports.tests[api];
+function getTestsObject (api) {
+    exports.tests[api] = exports.tests[api] || new TestModule(api);
+    return exports.tests[api];
 }
 
-function requireAllTestModules() {
-  // This finds all js-modules named "tests" (regardless of plugins they came from)
-  var test_modules = cordova.require('cordova/plugin_list')
-    .map(function(jsmodule) {
-      return jsmodule.id;
-    })
-    .filter(function(id) {
-      return /\.tests$/.test(id);
+function requireAllTestModules () {
+    // This finds all js-modules named "tests" (regardless of plugins they came from)
+    var test_modules = cordova.require('cordova/plugin_list') // eslint-disable-line no-undef
+        .map(function (jsmodule) {
+            return jsmodule.id;
+        })
+        .filter(function (id) {
+            return /\.tests$/.test(id);
+        });
+
+    // Map auto / manual test definitions for each, but without actually running the handlers
+    test_modules.forEach(function (id) {
+        try {
+            var plugintests = cordova.require(id); // eslint-disable-line no-undef
+
+            if (plugintests.hasOwnProperty('defineAutoTests')) {
+                getTestsObject(id).defineAutoTests = function () {
+                    describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
// eslint-disable-line no-undef
+                };
+            }
+
+            if (plugintests.hasOwnProperty('defineManualTests')) {
+                getTestsObject(id).defineManualTests = plugintests.defineManualTests.bind(plugintests);
+            }
+        } catch (ex) {
+            console.warn('Failed to load tests: ', id);
+
+        }
     });
-
-  // Map auto / manual test definitions for each, but without actually running the handlers
-  test_modules.forEach(function(id) {
-    try {
-      var plugintests = cordova.require(id);
-
-      if (plugintests.hasOwnProperty('defineAutoTests')) {
-        getTestsObject(id).defineAutoTests = function() {
-          describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
-        };
-      }
-
-      if (plugintests.hasOwnProperty('defineManualTests')) {
-        getTestsObject(id).defineManualTests = plugintests.defineManualTests.bind(plugintests);
-      }
-    } catch(ex) {
-      console.warn('Failed to load tests: ', id);
-      return;
-    }
-  });
 }
 
-function createJasmineInterface() {
-  var jasmine_helpers = require('cordova-plugin-test-framework.jasmine_helpers');
-  var jasmineInterface = jasmine_helpers.setUpJasmine();
-  return jasmineInterface;
+function createJasmineInterface () {
+    var jasmine_helpers = require('cordova-plugin-test-framework.jasmine_helpers');
+    var jasmineInterface = jasmine_helpers.setUpJasmine();
+    return jasmineInterface;
 }
 
-function attachJasmineInterfaceToGlobal() {
-  var jasmineInterface = createJasmineInterface();
-  for (var property in jasmineInterface) {
-    window[property] = jasmineInterface[property];
-  }
+function attachJasmineInterfaceToGlobal () {
+    var jasmineInterface = createJasmineInterface();
+    for (var property in jasmineInterface) {
+        window[property] = jasmineInterface[property];
+    }
 }
 
-function detachJasmineInterfaceFromGlobal() {
-  var jasmineInterface = createJasmineInterface();
-  for (var property in jasmineInterface) {
-    delete window[property];
-  }
+function detachJasmineInterfaceFromGlobal () {
+    var jasmineInterface = createJasmineInterface();
+    for (var property in jasmineInterface) {
+        delete window[property];
+    }
 }
 
-exports.defineAutoTests = function() {
-  requireAllTestModules();
-  attachJasmineInterfaceToGlobal();
-
-  Object.keys(exports.tests).forEach(function(key) {
-    if (!exports.tests[key].getEnabled())
-      return;
-    if (!exports.tests[key].hasOwnProperty('defineAutoTests'))
-      return;
-    exports.tests[key].defineAutoTests();
-  });
+exports.defineAutoTests = function () {
+    requireAllTestModules();
+    attachJasmineInterfaceToGlobal();
+
+    Object.keys(exports.tests).forEach(function (key) {
+        if (!exports.tests[key].getEnabled()) { return; }
+        if (!exports.tests[key].hasOwnProperty('defineAutoTests')) { return; }
+        exports.tests[key].defineAutoTests();
+    });
 };
 
-exports.defineManualTests = function(contentEl, beforeEach, createActionButton) {
-  requireAllTestModules();
-  detachJasmineInterfaceFromGlobal();
-
-  Object.keys(exports.tests).forEach(function(key) {
-    if (!exports.tests[key].getEnabled())
-      return;
-    if (!exports.tests[key].hasOwnProperty('defineManualTests'))
-      return;
-    createActionButton(key, function() {
-      beforeEach(key);
-      exports.tests[key].defineManualTests(contentEl, createActionButton);
+exports.defineManualTests = function (contentEl, beforeEach, createActionButton) {
+    requireAllTestModules();
+    detachJasmineInterfaceFromGlobal();
+
+    Object.keys(exports.tests).forEach(function (key) {
+        if (!exports.tests[key].getEnabled()) { return; }
+        if (!exports.tests[key].hasOwnProperty('defineManualTests')) { return; }
+        createActionButton(key, function () {
+            beforeEach(key);
+            exports.tests[key].defineManualTests(contentEl, createActionButton);
+        });
     });
-  });
 };
 
-exports.init = function() {
-  requireAllTestModules();
+exports.init = function () {
+    requireAllTestModules();
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message