You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@senssoft.apache.org by rf...@apache.org on 2018/06/07 17:10:53 UTC

[1/3] incubator-senssoft-useralejs git commit: Initial commit for test utilities to help with jsdom setup

Repository: incubator-senssoft-useralejs
Updated Branches:
  refs/heads/SENSSOFT-192 6302909ec -> d3ec8cb77


Initial commit for test utilities to help with jsdom setup


Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/1a1cb112
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/1a1cb112
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/1a1cb112

Branch: refs/heads/SENSSOFT-192
Commit: 1a1cb1124757c275caa171d623cd3cf9cf1c8f19
Parents: 6302909
Author: Rob Foley <rg...@draper.com>
Authored: Thu Jun 7 12:42:02 2018 -0400
Committer: Rob Foley <rg...@draper.com>
Committed: Thu Jun 7 13:09:11 2018 -0400

----------------------------------------------------------------------
 test/testUtils.js | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/1a1cb112/test/testUtils.js
----------------------------------------------------------------------
diff --git a/test/testUtils.js b/test/testUtils.js
new file mode 100644
index 0000000..e26933b
--- /dev/null
+++ b/test/testUtils.js
@@ -0,0 +1,38 @@
+import jsdom from 'jsdom';
+import fs from 'fs';
+
+import { version } from '../package.json';
+
+let scriptContent = null;
+
+export function resourceLoader(res, callback) {
+  if (scriptContent === null) {
+    scriptContent = fs.readFileSync(`build/userale-${version}.min.js`).toString();
+  }
+
+  const timeout = setTimeout(function() {
+    callback(null, scriptContent);
+  }, 0);
+
+  return {
+    abort : function() {
+      clearTimeout(timeout);
+      callback(new Error('Request canceled by user.'));
+    },
+  }
+}
+
+export function createEnv(html, doneCallback, extraConfig) {
+  let extra = (typeof extraConfig === 'undefined') ? {} : extraConfig;
+
+  return jsdom.env(Object.assign({}, {
+    html : html,
+    url : 'http://localhost:8080',
+    features : {
+      FetchExternalResources : ['script'],
+      ProcessExternalResources : ['script']
+    },
+    resourceLoader,
+    done : doneCallback,
+  }, extraConfig));
+}


[2/3] incubator-senssoft-useralejs git commit: Switched to using test utils (fixes broken tests)

Posted by rf...@apache.org.
Switched to using test utils (fixes broken tests)


Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/3a5eac66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/3a5eac66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/3a5eac66

Branch: refs/heads/SENSSOFT-192
Commit: 3a5eac66d5e460fc785d0544deae663f0d563d7a
Parents: 1a1cb11
Author: Rob Foley <rg...@draper.com>
Authored: Thu Jun 7 12:42:26 2018 -0400
Committer: Rob Foley <rg...@draper.com>
Committed: Thu Jun 7 13:09:21 2018 -0400

----------------------------------------------------------------------
 test/getInitialSettings_spec.js |  55 +++++++-----------
 test/main_spec.js               | 110 ++++++++++++++++-------------------
 2 files changed, 70 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/3a5eac66/test/getInitialSettings_spec.js
----------------------------------------------------------------------
diff --git a/test/getInitialSettings_spec.js b/test/getInitialSettings_spec.js
index 9705409..2063332 100644
--- a/test/getInitialSettings_spec.js
+++ b/test/getInitialSettings_spec.js
@@ -18,6 +18,7 @@ import { expect } from 'chai';
 import jsdom from 'jsdom';
 import fs from 'fs';
 
+import { createEnv } from './testUtils';
 import { timeStampScale } from '../src/getInitialSettings.js';
 import { version } from '../package.json';
 
@@ -67,47 +68,31 @@ describe('getInitialSettings', () => {
     it('fetches all settings from a script tag', (done) => {
       const html = fs.readFileSync(__dirname + '/getInitialSettings_fetchAll.html');
 
-      jsdom.env({
-        html : html,
-        url : 'file://' + __dirname + '/getInitialSettings_fetchAll.html',
-        features : {
-          FetchExternalResources : ['script'],
-          ProcessExternalResources : ['script']
-        },
-        done : (err, window) => {
-          const config = window.userale.options();
-          expect(config).to.have.property('autostart', true);
-          expect(config).to.have.property('url', 'http://test.com');
-          expect(config).to.have.property('transmitInterval', 100);
-          expect(config).to.have.property('logCountThreshold', 10);
-          expect(config).to.have.property('userId', 'testuser');
-          expect(config).to.have.property('version', '1.0.0');
-          expect(config).to.have.property('logDetails', false);
-          expect(config).to.have.property('resolution', 100);
-          expect(config).to.have.property('toolName', 'testtool');
-          window.close();
-          done();
-        }
+      createEnv(html, (err, window) => {
+        const config = window.userale.options();
+        expect(config).to.have.property('autostart', true);
+        expect(config).to.have.property('url', 'http://test.com');
+        expect(config).to.have.property('transmitInterval', 100);
+        expect(config).to.have.property('logCountThreshold', 10);
+        expect(config).to.have.property('userId', 'testuser');
+        expect(config).to.have.property('version', '1.0.0');
+        expect(config).to.have.property('logDetails', false);
+        expect(config).to.have.property('resolution', 100);
+        expect(config).to.have.property('toolName', 'testtool');
+        window.close();
+        done();
       });
     });
 
     it('grabs user id from params', (done) => {
       const html = fs.readFileSync(__dirname + '/getInitialSettings_userParam.html');
 
-      jsdom.env({
-        html : html,
-        url : 'file://' + __dirname + '/getInitialSettings_userParam.html?user=testuser',
-        features : {
-          FetchExternalResources : ['script'],
-          ProcessExternalResources : ['script']
-        },
-        done : (err, window) => {
-          const config = window.userale.options();
-          expect(config.userId).to.equal('testuser');
-          window.close();
-          done();
-        }
-      });
+      createEnv(html, (err, window) => {
+        const config = window.userale.options();
+        expect(config.userId).to.equal('testuser');
+        window.close();
+        done();
+      }, { url : 'http://localhost:8080?user=testuser' });
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/3a5eac66/test/main_spec.js
----------------------------------------------------------------------
diff --git a/test/main_spec.js b/test/main_spec.js
index 950ce75..26f9f59 100644
--- a/test/main_spec.js
+++ b/test/main_spec.js
@@ -18,6 +18,8 @@ import { expect } from 'chai';
 import jsdom from 'jsdom';
 import fs from 'fs';
 
+import { createEnv } from './testUtils';
+
 describe('Userale API', () => {
   const url = 'file://' + __dirname + '/main.html';
   const html = fs.readFileSync(__dirname + '/main.html');
@@ -27,84 +29,72 @@ describe('Userale API', () => {
   };
 
   it('provides configs', (done) => {
-    jsdom.env({
-      html, url, features,
-      done : (err, window) => {
-        const config = window.userale.options();
-        expect(config).to.be.an('object');
-        expect(config).to.have.all.keys([
-          'on',
-          'useraleVersion',
-          'autostart',
-          'url',
-          'transmitInterval',
-          'logCountThreshold',
-          'userId',
-          'version',
-          'logDetails',
-          'resolution',
-          'toolName',
-          'userFromParams',
-          'time',
-        ]);
-        window.close();
-        done();
-      }
+    createEnv(html, (err, window) => {
+      const config = window.userale.options();
+      expect(config).to.be.an('object');
+      expect(config).to.have.all.keys([
+        'on',
+        'useraleVersion',
+        'autostart',
+        'url',
+        'transmitInterval',
+        'logCountThreshold',
+        'userId',
+        'version',
+        'logDetails',
+        'resolution',
+        'toolName',
+        'userFromParams',
+        'time',
+      ]);
+      window.close();
+      done();
     });
   });
 
   it('edits configs', (done) => {
-    jsdom.env({
-      html, url, features,
-      done : (err, window) => {
-        const config = window.userale.options();
-        const interval = config.transmitInterval;
-        window.userale.options({
-          transmitInterval : interval + 10
-        });
-        const newConfig = window.userale.options();
+    createEnv(html, (err, window) => {
+      const config = window.userale.options();
+      const interval = config.transmitInterval;
+      window.userale.options({
+        transmitInterval : interval + 10
+      });
+      const newConfig = window.userale.options();
 
-        expect(newConfig.transmitInterval).to.equal(interval + 10);
-        window.close();
-        done();
-      }
+      expect(newConfig.transmitInterval).to.equal(interval + 10);
+      window.close();
+      done();
     });
   });
 
   it('starts + stops', (done) => {
-    jsdom.env({
-      html, url, features,
-      done : (err, window) => {
-        setTimeout(() => {
-          const { userale } = window;
-          expect(userale.options().on).to.equal(true);
+    createEnv(html, (err, window) => {
+      setTimeout(() => {
+        const { userale } = window;
+        expect(userale.options().on).to.equal(true);
 
-          userale.stop();
-          expect(userale.options().on).to.equal(false);
+        userale.stop();
+        expect(userale.options().on).to.equal(false);
 
-          userale.start();
-          expect(userale.options().on).to.equal(true);
+        userale.start();
+        expect(userale.options().on).to.equal(true);
 
-          window.close();
-          done();
-        }, 200);
-      }
+        window.close();
+        done();
+      }, 200);
     });
   });
 
   it('sends custom logs', (done) => {
-    jsdom.env({
-      html, url, features,
-      done: (err, window) => {
-        const { userale } = window;
+    createEnv(html, (err, window) => {
+      const { userale } = window;
 
-        expect(userale.log({})).to.equal(true);
-        expect(userale.log()).to.equal(false);
-        expect(userale.log(null)).to.equal(false);
+      expect(userale.log({})).to.equal(true);
+      expect(userale.log()).to.equal(false);
+      expect(userale.log(null)).to.equal(false);
 
-        window.close();
-        done();
-      }
+      window.close();
+      done();
     });
   });
 });


[3/3] incubator-senssoft-useralejs git commit: Added sessionID key

Posted by rf...@apache.org.
Added sessionID key


Project: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/d3ec8cb7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/d3ec8cb7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/d3ec8cb7

Branch: refs/heads/SENSSOFT-192
Commit: d3ec8cb7755d6a36778338de816b934a2e1652b3
Parents: 3a5eac6
Author: Rob Foley <rg...@draper.com>
Authored: Thu Jun 7 13:10:44 2018 -0400
Committer: Rob Foley <rg...@draper.com>
Committed: Thu Jun 7 13:10:44 2018 -0400

----------------------------------------------------------------------
 test/main_spec.js | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/d3ec8cb7/test/main_spec.js
----------------------------------------------------------------------
diff --git a/test/main_spec.js b/test/main_spec.js
index 26f9f59..f66953a 100644
--- a/test/main_spec.js
+++ b/test/main_spec.js
@@ -40,6 +40,7 @@ describe('Userale API', () => {
         'transmitInterval',
         'logCountThreshold',
         'userId',
+        'sessionID',
         'version',
         'logDetails',
         'resolution',