You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flagon.apache.org by GitBox <gi...@apache.org> on 2021/03/03 12:28:33 UTC

[GitHub] [incubator-flagon-useralejs] UncleGedd opened a new pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

UncleGedd opened a new pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40


   ## Updates JSDOM: [JIRA Ticket](https://issues.apache.org/jira/secure/RapidBoard.jspa?rapidView=324&projectKey=FLAGON&view=detail&selectedIssue=FLAGON-339)
   
   - updates JSDOM to latest version `16.4.0`
   - adds `global-jsdom` and removes the deprecated `jsdom-global` package
   - adds `@babel/plugin-transform-runtime` to use `async/await` syntax in tests
   - removes `packageLogs.html` as it wasn't required to run the tests 
   - modifies the `detectBrowser` function in `packageLogs.js` to fix a bug where `packageLog` tests couldn't be run independently


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-flagon-useralejs] poorejc commented on a change in pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

Posted by GitBox <gi...@apache.org>.
poorejc commented on a change in pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40#discussion_r586997689



##########
File path: test/packageLogs_spec.js
##########
@@ -14,356 +14,316 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import { expect } from 'chai';
-import jsdom from 'jsdom';
-import 'jsdom-global/register';
-import fs from 'fs';
+import {expect} from 'chai';
+import {JSDOM} from 'jsdom';
+import 'global-jsdom/register'
 import {
-  packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
-  extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
+    packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
+    extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
 } from '../src/packageLogs';
 
 describe('packageLogs', () => {
-  const url = 'file://' + __dirname + '/packageLogs.html';
-  const html = fs.readFileSync(__dirname + '/packageLogs.html');
-
-  describe('setLogFilter', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogFilter(func);
-      expect(filterHandler).to.equal(func);
+    describe('setLogFilter', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogFilter(func);
+            expect(filterHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogFilter(x => true);
+            setLogFilter(null);
+            expect(filterHandler).to.equal(null);
+        });
     });
-    it('allows the handler to be nulled', () => {
-      setLogFilter(x => true);
-      setLogFilter(null);
-      expect(filterHandler).to.equal(null);
-    });
-  });
 
-  describe('setLogMapper', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogMapper(func);
-      expect(mapHandler).to.equal(func);
-    });
-    it('allows the handler to be nulled', () => {
-      setLogMapper(x => true);
-      setLogMapper(null);
-      expect(mapHandler).to.equal(null);
+    describe('setLogMapper', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogMapper(func);
+            expect(mapHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogMapper(x => true);
+            setLogMapper(null);
+            expect(mapHandler).to.equal(null);
+        });
     });
-  });
-
-  describe('packageLog', () => {
-    it('only executes if on', (done) => {
-      initPackager([], { on: true });
-      const evt = { target: {}, type: 'test' };
-      expect(packageLog(evt)).to.equal(true);
 
-      initPackager([], { on: false });
-      expect(packageLog({})).to.equal(false);
-
-      done();
-    });
-    it('calls detailFcn with the event as an argument if provided', (done) => {
-      initPackager([], { on: true });
-      let called = false;
-      const evt = { target: {}, type: 'test' };
-      const detailFcn = (e) => {
-        called = true;
-        expect(e).to.equal(evt);
-      };
-      packageLog(evt, detailFcn);
-      expect(called).to.equal(true);
-      done();
+    describe('packageLog', () => {
+        it('only executes if on', () => {
+            initPackager([], {on: true});
+            const evt = {target: {}, type: 'test'};
+            expect(packageLog(evt)).to.equal(true);
+
+            initPackager([], {on: false});
+            expect(packageLog({})).to.equal(false);
+        });
+        it('calls detailFcn with the event as an argument if provided', () => {
+            initPackager([], {on: true});
+            let called = false;
+            const evt = {target: {}, type: 'test'};
+            const detailFcn = (e) => {
+                called = true;
+                expect(e).to.equal(evt);
+            };
+            packageLog(evt, detailFcn);
+            expect(called).to.equal(true);
+        });
+        it('packages logs', () => {
+            initPackager([], {on: true});
+            const evt = {
+                target: {},
+                type: 'test'
+            };
+            expect(packageLog(evt)).to.equal(true);
+        });
+
+        it('filters logs when a handler is assigned and returns false', () => {
+            let filterCalled = false;
+            const filter = (log) => {
+                filterCalled = true;
+                return false;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+
+            setLogFilter(filter);
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+        });
+
+        it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
+            let mapperCalled = false;
+
+            const mappedLog = {type: 'foo'};
+            const mapper = (log) => {
+                mapperCalled = true;
+                return mappedLog;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+
+            setLogMapper(mapper);
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(true);
+            expect(logs.indexOf(mappedLog)).to.equal(0);
+        });
+
+        it('does not call the map handler if the log is filtered out', () => {
+            let mapperCalled = false;
+            const filter = () => false;
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(false);
+        });
+
+        it('does not attempt to call a non-function filter/mapper', () => {
+            let filterCalled = false;
+            let mapperCalled = false;
+            const filter = () => {
+                filterCalled = true;
+                return true;
+            };
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(filterCalled).to.equal(true);
+            expect(mapperCalled).to.equal(true);
+
+            setLogFilter('foo');
+            setLogMapper('bar');
+
+            packageLog(evt);
+            expect(logs.length).to.equal(2);
+        });
     });
-    it('packages logs', (done) => {
-      initPackager([], { on: true });
-      const evt = {
-        target: {},
-        type: 'test'
-      };
-      expect(packageLog(evt)).to.equal(true);
-      done();
-    });
-
-    it('filters logs when a handler is assigned and returns false', () => {
-      let filterCalled = false;
-      const filter = (log) => {
-        filterCalled = true;
-        return false;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      packageLog(evt);
 
-      expect(logs.length).to.equal(1);
-
-      setLogFilter(filter);
-      packageLog(evt);
-
-      expect(logs.length).to.equal(1);
+    describe('extractTimeFields', () => {
+        it('returns the millisecond and microsecond portions of a timestamp', () => {
+            const timeStamp = 123.456;
+            const fields = {milli: 123, micro: 0.456};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('sets micro to 0 when no decimal is present', () => {
+            const timeStamp = 123;
+            const fields = {milli: 123, micro: 0};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('always returns an object', () => {
+            const stampVariants = [
+                null,
+                'foobar',
+                {foo: 'bar'},
+                undefined,
+                ['foo', 'bar'],
+                123,
+            ];
+
+            stampVariants.forEach((variant) => {
+                const ret = extractTimeFields(variant);
+                expect(!!ret).to.equal(true);
+                expect(typeof ret).to.equal('object');
+            });
+        });
     });
 
-    it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
-      let mapperCalled = false;
-
-      const mappedLog = { type: 'foo' };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return mappedLog;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-
-      setLogMapper(mapper);
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(true);
-      expect(logs.indexOf(mappedLog)).to.equal(0);
+    describe('getLocation', () => {
+        it('returns event page location', () => {
+            new JSDOM(``);
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                e.pageX = 0;
+                e.pageY = 0;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('calculates page location if unavailable', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                document.documentElement.scrollLeft = 0;
+                document.documentElement.scrollTop = 0;
+                const originalDocument = global.document;
+                global.document = document;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+                global.document = originalDocument;
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('fails to null', () => {
+            let hadError = false;
+            try {
+                getLocation(null);
+            } catch (e) {
+                hadError = true;
+            }
+            expect(hadError).to.equal(true);
+        });
     });
 
-    it('does not call the map handler if the log is filtered out', () => {
-      let mapperCalled = false;
-      const filter = () => false;
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(false);
-    });
-
-    it('does not attempt to call a non-function filter/mapper', () => {
-      let filterCalled = false;
-      let mapperCalled = false;
-      const filter = () => {
-        filterCalled = true;
-        return true;
-      };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(filterCalled).to.equal(true);
-      expect(mapperCalled).to.equal(true);
-
-      setLogFilter('foo');
-      setLogMapper('bar');
-
-      packageLog(evt);
-      expect(logs.length).to.equal(2);
-    });
-  });
-
-  describe('extractTimeFields', () => {
-    it('returns the millisecond and microsecond portions of a timestamp', () => {
-      const timeStamp = 123.456;
-      const fields = { milli: 123, micro: 0.456 };
-      const ret = extractTimeFields(timeStamp);
-
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
+    describe('selectorizePath', () => {
+        it('returns a new array of the same length provided', () => {
+            const arr = [{}, {}];
+            const ret = selectorizePath(arr);
+            expect(ret).to.be.instanceof(Array);
+            expect(ret).to.not.equal(arr);
+            expect(ret.length).to.equal(arr.length);
+        });
     });
-    it('sets micro to 0 when no decimal is present', () => {
-      const timeStamp = 123;
-      const fields = { milli: 123, micro: 0 };
-      const ret = extractTimeFields(timeStamp);
 
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
-    });
-    it('always returns an object', () => {
-      const stampVariants = [
-        null,
-        'foobar',
-        { foo: 'bar' },
-        undefined,
-        ['foo', 'bar'],
-        123,
-      ];
-
-      stampVariants.forEach((variant) => {
-        const ret = extractTimeFields(variant);
-        expect(!!ret).to.equal(true);
-        expect(typeof ret).to.equal('object');
-      });
-    });
-  });
-
-  describe('getLocation', () => {
-    it('returns event page location', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            e.pageX = 0;
-            e.pageY = 0;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
-    });
-
-    it('calculates page location if unavailable', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            document.documentElement.scrollLeft = 0;
-            document.documentElement.scrollTop = 0;
-            const originalDocument = global.document;
-            global.document = document;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            global.document = originalDocument;
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
+    describe('getSelector', () => {
+        it('builds a selector', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const element = document.createElement('div');
+            expect(getSelector(element)).to.equal('div');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar');
+            element.removeAttribute('id');
+            element.classList.add('baz');
+            expect(getSelector(element)).to.equal('div.baz');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar.baz');
+        });
     });
 
-    it('fails to null', (done) => {
-      let hadError = false;
-      try {
-        getLocation(null);
-      } catch (e) {
-        hadError = true;
-      }
-      expect(hadError).to.equal(true);
-      done();
-    });
-  });
-
-  describe('selectorizePath', () => {
-    it('returns a new array of the same length provided', (done) => {
-      const arr = [{}, {}];
-      const ret = selectorizePath(arr);
-      expect(ret).to.be.instanceof(Array);
-      expect(ret).to.not.equal(arr);
-      expect(ret.length).to.equal(arr.length);
-      done();
-    });
-  });
-
-  describe('getSelector', () => {
-    it('builds a selector', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const element = document.createElement('div');
-          expect(getSelector(element)).to.equal('div');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar');
-          element.removeAttribute('id');
-          element.classList.add('baz');
-          expect(getSelector(element)).to.equal('div.baz');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar.baz');
-          done();
-        },
-      });
+    it('identifies window', () => {
+        new JSDOM(``)
+        expect(getSelector(window)).to.equal('Window');
     });
 
-    it('identifies window', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          expect(getSelector(window)).to.equal('Window');
-          done();
-        },
-      });
+    it('handles a non-null unknown value', () => {

Review comment:
       making minor edit here to pull 'identifies window' into describe('getSelector')
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-flagon-useralejs] poorejc commented on a change in pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

Posted by GitBox <gi...@apache.org>.
poorejc commented on a change in pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40#discussion_r587015695



##########
File path: test/packageLogs_spec.js
##########
@@ -14,356 +14,316 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import { expect } from 'chai';
-import jsdom from 'jsdom';
-import 'jsdom-global/register';
-import fs from 'fs';
+import {expect} from 'chai';
+import {JSDOM} from 'jsdom';
+import 'global-jsdom/register'
 import {
-  packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
-  extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
+    packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
+    extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
 } from '../src/packageLogs';
 
 describe('packageLogs', () => {
-  const url = 'file://' + __dirname + '/packageLogs.html';
-  const html = fs.readFileSync(__dirname + '/packageLogs.html');
-
-  describe('setLogFilter', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogFilter(func);
-      expect(filterHandler).to.equal(func);
+    describe('setLogFilter', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogFilter(func);
+            expect(filterHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogFilter(x => true);
+            setLogFilter(null);
+            expect(filterHandler).to.equal(null);
+        });
     });
-    it('allows the handler to be nulled', () => {
-      setLogFilter(x => true);
-      setLogFilter(null);
-      expect(filterHandler).to.equal(null);
-    });
-  });
 
-  describe('setLogMapper', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogMapper(func);
-      expect(mapHandler).to.equal(func);
-    });
-    it('allows the handler to be nulled', () => {
-      setLogMapper(x => true);
-      setLogMapper(null);
-      expect(mapHandler).to.equal(null);
+    describe('setLogMapper', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogMapper(func);
+            expect(mapHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogMapper(x => true);
+            setLogMapper(null);
+            expect(mapHandler).to.equal(null);
+        });
     });
-  });
-
-  describe('packageLog', () => {
-    it('only executes if on', (done) => {
-      initPackager([], { on: true });
-      const evt = { target: {}, type: 'test' };
-      expect(packageLog(evt)).to.equal(true);
 
-      initPackager([], { on: false });
-      expect(packageLog({})).to.equal(false);
-
-      done();
-    });
-    it('calls detailFcn with the event as an argument if provided', (done) => {
-      initPackager([], { on: true });
-      let called = false;
-      const evt = { target: {}, type: 'test' };
-      const detailFcn = (e) => {
-        called = true;
-        expect(e).to.equal(evt);
-      };
-      packageLog(evt, detailFcn);
-      expect(called).to.equal(true);
-      done();
+    describe('packageLog', () => {
+        it('only executes if on', () => {
+            initPackager([], {on: true});
+            const evt = {target: {}, type: 'test'};
+            expect(packageLog(evt)).to.equal(true);
+
+            initPackager([], {on: false});
+            expect(packageLog({})).to.equal(false);
+        });
+        it('calls detailFcn with the event as an argument if provided', () => {
+            initPackager([], {on: true});
+            let called = false;
+            const evt = {target: {}, type: 'test'};
+            const detailFcn = (e) => {
+                called = true;
+                expect(e).to.equal(evt);
+            };
+            packageLog(evt, detailFcn);
+            expect(called).to.equal(true);
+        });
+        it('packages logs', () => {
+            initPackager([], {on: true});
+            const evt = {
+                target: {},
+                type: 'test'
+            };
+            expect(packageLog(evt)).to.equal(true);
+        });
+
+        it('filters logs when a handler is assigned and returns false', () => {
+            let filterCalled = false;
+            const filter = (log) => {
+                filterCalled = true;
+                return false;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+
+            setLogFilter(filter);
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+        });
+
+        it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
+            let mapperCalled = false;
+
+            const mappedLog = {type: 'foo'};
+            const mapper = (log) => {
+                mapperCalled = true;
+                return mappedLog;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+
+            setLogMapper(mapper);
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(true);
+            expect(logs.indexOf(mappedLog)).to.equal(0);
+        });
+
+        it('does not call the map handler if the log is filtered out', () => {
+            let mapperCalled = false;
+            const filter = () => false;
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(false);
+        });
+
+        it('does not attempt to call a non-function filter/mapper', () => {
+            let filterCalled = false;
+            let mapperCalled = false;
+            const filter = () => {
+                filterCalled = true;
+                return true;
+            };
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(filterCalled).to.equal(true);
+            expect(mapperCalled).to.equal(true);
+
+            setLogFilter('foo');
+            setLogMapper('bar');
+
+            packageLog(evt);
+            expect(logs.length).to.equal(2);
+        });
     });
-    it('packages logs', (done) => {
-      initPackager([], { on: true });
-      const evt = {
-        target: {},
-        type: 'test'
-      };
-      expect(packageLog(evt)).to.equal(true);
-      done();
-    });
-
-    it('filters logs when a handler is assigned and returns false', () => {
-      let filterCalled = false;
-      const filter = (log) => {
-        filterCalled = true;
-        return false;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      packageLog(evt);
 
-      expect(logs.length).to.equal(1);
-
-      setLogFilter(filter);
-      packageLog(evt);
-
-      expect(logs.length).to.equal(1);
+    describe('extractTimeFields', () => {
+        it('returns the millisecond and microsecond portions of a timestamp', () => {
+            const timeStamp = 123.456;
+            const fields = {milli: 123, micro: 0.456};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('sets micro to 0 when no decimal is present', () => {
+            const timeStamp = 123;
+            const fields = {milli: 123, micro: 0};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('always returns an object', () => {
+            const stampVariants = [
+                null,
+                'foobar',
+                {foo: 'bar'},
+                undefined,
+                ['foo', 'bar'],
+                123,
+            ];
+
+            stampVariants.forEach((variant) => {
+                const ret = extractTimeFields(variant);
+                expect(!!ret).to.equal(true);
+                expect(typeof ret).to.equal('object');
+            });
+        });
     });
 
-    it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
-      let mapperCalled = false;
-
-      const mappedLog = { type: 'foo' };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return mappedLog;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-
-      setLogMapper(mapper);
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(true);
-      expect(logs.indexOf(mappedLog)).to.equal(0);
+    describe('getLocation', () => {
+        it('returns event page location', () => {
+            new JSDOM(``);
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                e.pageX = 0;
+                e.pageY = 0;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('calculates page location if unavailable', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                document.documentElement.scrollLeft = 0;
+                document.documentElement.scrollTop = 0;
+                const originalDocument = global.document;
+                global.document = document;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+                global.document = originalDocument;
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('fails to null', () => {
+            let hadError = false;
+            try {
+                getLocation(null);
+            } catch (e) {
+                hadError = true;
+            }
+            expect(hadError).to.equal(true);
+        });
     });
 
-    it('does not call the map handler if the log is filtered out', () => {
-      let mapperCalled = false;
-      const filter = () => false;
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(false);
-    });
-
-    it('does not attempt to call a non-function filter/mapper', () => {
-      let filterCalled = false;
-      let mapperCalled = false;
-      const filter = () => {
-        filterCalled = true;
-        return true;
-      };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(filterCalled).to.equal(true);
-      expect(mapperCalled).to.equal(true);
-
-      setLogFilter('foo');
-      setLogMapper('bar');
-
-      packageLog(evt);
-      expect(logs.length).to.equal(2);
-    });
-  });
-
-  describe('extractTimeFields', () => {
-    it('returns the millisecond and microsecond portions of a timestamp', () => {
-      const timeStamp = 123.456;
-      const fields = { milli: 123, micro: 0.456 };
-      const ret = extractTimeFields(timeStamp);
-
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
+    describe('selectorizePath', () => {
+        it('returns a new array of the same length provided', () => {
+            const arr = [{}, {}];
+            const ret = selectorizePath(arr);
+            expect(ret).to.be.instanceof(Array);
+            expect(ret).to.not.equal(arr);
+            expect(ret.length).to.equal(arr.length);
+        });
     });
-    it('sets micro to 0 when no decimal is present', () => {
-      const timeStamp = 123;
-      const fields = { milli: 123, micro: 0 };
-      const ret = extractTimeFields(timeStamp);
 
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
-    });
-    it('always returns an object', () => {
-      const stampVariants = [
-        null,
-        'foobar',
-        { foo: 'bar' },
-        undefined,
-        ['foo', 'bar'],
-        123,
-      ];
-
-      stampVariants.forEach((variant) => {
-        const ret = extractTimeFields(variant);
-        expect(!!ret).to.equal(true);
-        expect(typeof ret).to.equal('object');
-      });
-    });
-  });
-
-  describe('getLocation', () => {
-    it('returns event page location', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            e.pageX = 0;
-            e.pageY = 0;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
-    });
-
-    it('calculates page location if unavailable', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            document.documentElement.scrollLeft = 0;
-            document.documentElement.scrollTop = 0;
-            const originalDocument = global.document;
-            global.document = document;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            global.document = originalDocument;
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
+    describe('getSelector', () => {
+        it('builds a selector', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const element = document.createElement('div');
+            expect(getSelector(element)).to.equal('div');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar');
+            element.removeAttribute('id');
+            element.classList.add('baz');
+            expect(getSelector(element)).to.equal('div.baz');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar.baz');
+        });
     });
 
-    it('fails to null', (done) => {
-      let hadError = false;
-      try {
-        getLocation(null);
-      } catch (e) {
-        hadError = true;
-      }
-      expect(hadError).to.equal(true);
-      done();
-    });
-  });
-
-  describe('selectorizePath', () => {
-    it('returns a new array of the same length provided', (done) => {
-      const arr = [{}, {}];
-      const ret = selectorizePath(arr);
-      expect(ret).to.be.instanceof(Array);
-      expect(ret).to.not.equal(arr);
-      expect(ret.length).to.equal(arr.length);
-      done();
-    });
-  });
-
-  describe('getSelector', () => {
-    it('builds a selector', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const element = document.createElement('div');
-          expect(getSelector(element)).to.equal('div');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar');
-          element.removeAttribute('id');
-          element.classList.add('baz');
-          expect(getSelector(element)).to.equal('div.baz');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar.baz');
-          done();
-        },
-      });
+    it('identifies window', () => {
+        new JSDOM(``)
+        expect(getSelector(window)).to.equal('Window');
     });
 
-    it('identifies window', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          expect(getSelector(window)).to.equal('Window');
-          done();
-        },
-      });
+    it('handles a non-null unknown value', () => {

Review comment:
       Merged @UncleGedd's generous contribution. Note: pushed minor mods to resolve minor issue of orphaned getSelector tests. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-flagon-useralejs] poorejc commented on pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

Posted by GitBox <gi...@apache.org>.
poorejc commented on pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40#issuecomment-789906379


   @UncleGedd Thanks for this! Looks great! I'll test locally tonight and if things look good, I'll pull into our test branch and then into Master. Again, many thannks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-flagon-useralejs] asfgit merged pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

Posted by GitBox <gi...@apache.org>.
asfgit merged pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-flagon-useralejs] poorejc commented on a change in pull request #40: [FLAGON-339] Updates JSDOM and refactors tests

Posted by GitBox <gi...@apache.org>.
poorejc commented on a change in pull request #40:
URL: https://github.com/apache/incubator-flagon-useralejs/pull/40#discussion_r586996717



##########
File path: test/packageLogs_spec.js
##########
@@ -14,356 +14,316 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import { expect } from 'chai';
-import jsdom from 'jsdom';
-import 'jsdom-global/register';
-import fs from 'fs';
+import {expect} from 'chai';
+import {JSDOM} from 'jsdom';
+import 'global-jsdom/register'
 import {
-  packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
-  extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
+    packageLog, initPackager, getLocation, getSelector, buildPath, selectorizePath,
+    extractTimeFields, filterHandler, mapHandler, setLogFilter, setLogMapper, logs,
 } from '../src/packageLogs';
 
 describe('packageLogs', () => {
-  const url = 'file://' + __dirname + '/packageLogs.html';
-  const html = fs.readFileSync(__dirname + '/packageLogs.html');
-
-  describe('setLogFilter', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogFilter(func);
-      expect(filterHandler).to.equal(func);
+    describe('setLogFilter', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogFilter(func);
+            expect(filterHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogFilter(x => true);
+            setLogFilter(null);
+            expect(filterHandler).to.equal(null);
+        });
     });
-    it('allows the handler to be nulled', () => {
-      setLogFilter(x => true);
-      setLogFilter(null);
-      expect(filterHandler).to.equal(null);
-    });
-  });
 
-  describe('setLogMapper', () => {
-    it('assigns the handler to the provided value', () => {
-      const func = x => true;
-      setLogMapper(func);
-      expect(mapHandler).to.equal(func);
-    });
-    it('allows the handler to be nulled', () => {
-      setLogMapper(x => true);
-      setLogMapper(null);
-      expect(mapHandler).to.equal(null);
+    describe('setLogMapper', () => {
+        it('assigns the handler to the provided value', () => {
+            const func = x => true;
+            setLogMapper(func);
+            expect(mapHandler).to.equal(func);
+        });
+        it('allows the handler to be nulled', () => {
+            setLogMapper(x => true);
+            setLogMapper(null);
+            expect(mapHandler).to.equal(null);
+        });
     });
-  });
-
-  describe('packageLog', () => {
-    it('only executes if on', (done) => {
-      initPackager([], { on: true });
-      const evt = { target: {}, type: 'test' };
-      expect(packageLog(evt)).to.equal(true);
 
-      initPackager([], { on: false });
-      expect(packageLog({})).to.equal(false);
-
-      done();
-    });
-    it('calls detailFcn with the event as an argument if provided', (done) => {
-      initPackager([], { on: true });
-      let called = false;
-      const evt = { target: {}, type: 'test' };
-      const detailFcn = (e) => {
-        called = true;
-        expect(e).to.equal(evt);
-      };
-      packageLog(evt, detailFcn);
-      expect(called).to.equal(true);
-      done();
+    describe('packageLog', () => {
+        it('only executes if on', () => {
+            initPackager([], {on: true});
+            const evt = {target: {}, type: 'test'};
+            expect(packageLog(evt)).to.equal(true);
+
+            initPackager([], {on: false});
+            expect(packageLog({})).to.equal(false);
+        });
+        it('calls detailFcn with the event as an argument if provided', () => {
+            initPackager([], {on: true});
+            let called = false;
+            const evt = {target: {}, type: 'test'};
+            const detailFcn = (e) => {
+                called = true;
+                expect(e).to.equal(evt);
+            };
+            packageLog(evt, detailFcn);
+            expect(called).to.equal(true);
+        });
+        it('packages logs', () => {
+            initPackager([], {on: true});
+            const evt = {
+                target: {},
+                type: 'test'
+            };
+            expect(packageLog(evt)).to.equal(true);
+        });
+
+        it('filters logs when a handler is assigned and returns false', () => {
+            let filterCalled = false;
+            const filter = (log) => {
+                filterCalled = true;
+                return false;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+
+            setLogFilter(filter);
+            packageLog(evt);
+
+            expect(logs.length).to.equal(1);
+        });
+
+        it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
+            let mapperCalled = false;
+
+            const mappedLog = {type: 'foo'};
+            const mapper = (log) => {
+                mapperCalled = true;
+                return mappedLog;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+
+            setLogMapper(mapper);
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(true);
+            expect(logs.indexOf(mappedLog)).to.equal(0);
+        });
+
+        it('does not call the map handler if the log is filtered out', () => {
+            let mapperCalled = false;
+            const filter = () => false;
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(mapperCalled).to.equal(false);
+        });
+
+        it('does not attempt to call a non-function filter/mapper', () => {
+            let filterCalled = false;
+            let mapperCalled = false;
+            const filter = () => {
+                filterCalled = true;
+                return true;
+            };
+            const mapper = (log) => {
+                mapperCalled = true;
+                return log;
+            };
+
+            const evt = {
+                target: {},
+                type: 'test',
+            };
+
+            initPackager([], {on: true});
+            setLogFilter(filter);
+            setLogMapper(mapper);
+
+            packageLog(evt);
+
+            expect(filterCalled).to.equal(true);
+            expect(mapperCalled).to.equal(true);
+
+            setLogFilter('foo');
+            setLogMapper('bar');
+
+            packageLog(evt);
+            expect(logs.length).to.equal(2);
+        });
     });
-    it('packages logs', (done) => {
-      initPackager([], { on: true });
-      const evt = {
-        target: {},
-        type: 'test'
-      };
-      expect(packageLog(evt)).to.equal(true);
-      done();
-    });
-
-    it('filters logs when a handler is assigned and returns false', () => {
-      let filterCalled = false;
-      const filter = (log) => {
-        filterCalled = true;
-        return false;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      packageLog(evt);
 
-      expect(logs.length).to.equal(1);
-
-      setLogFilter(filter);
-      packageLog(evt);
-
-      expect(logs.length).to.equal(1);
+    describe('extractTimeFields', () => {
+        it('returns the millisecond and microsecond portions of a timestamp', () => {
+            const timeStamp = 123.456;
+            const fields = {milli: 123, micro: 0.456};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('sets micro to 0 when no decimal is present', () => {
+            const timeStamp = 123;
+            const fields = {milli: 123, micro: 0};
+            const ret = extractTimeFields(timeStamp);
+
+            expect(ret.milli).to.equal(fields.milli);
+            expect(ret.micro).to.equal(fields.micro);
+        });
+        it('always returns an object', () => {
+            const stampVariants = [
+                null,
+                'foobar',
+                {foo: 'bar'},
+                undefined,
+                ['foo', 'bar'],
+                123,
+            ];
+
+            stampVariants.forEach((variant) => {
+                const ret = extractTimeFields(variant);
+                expect(!!ret).to.equal(true);
+                expect(typeof ret).to.equal('object');
+            });
+        });
     });
 
-    it('assigns logs to the mapper\'s return value if a handler is assigned', () => {
-      let mapperCalled = false;
-
-      const mappedLog = { type: 'foo' };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return mappedLog;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-
-      setLogMapper(mapper);
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(true);
-      expect(logs.indexOf(mappedLog)).to.equal(0);
+    describe('getLocation', () => {
+        it('returns event page location', () => {
+            new JSDOM(``);
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                e.pageX = 0;
+                e.pageY = 0;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('calculates page location if unavailable', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const ele = document.createElement('div');
+            const evt = new window.MouseEvent('click', {
+                'view': window,
+                'bubbles': true,
+                'cancelable': true
+            });
+            document.body.appendChild(ele);
+            ele.addEventListener('click', (e) => {
+                document.documentElement.scrollLeft = 0;
+                document.documentElement.scrollTop = 0;
+                const originalDocument = global.document;
+                global.document = document;
+                expect(getLocation(e)).to.deep.equal({x: 0, y: 0});
+                global.document = originalDocument;
+            });
+            ele.dispatchEvent(evt);
+        });
+
+        it('fails to null', () => {
+            let hadError = false;
+            try {
+                getLocation(null);
+            } catch (e) {
+                hadError = true;
+            }
+            expect(hadError).to.equal(true);
+        });
     });
 
-    it('does not call the map handler if the log is filtered out', () => {
-      let mapperCalled = false;
-      const filter = () => false;
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(mapperCalled).to.equal(false);
-    });
-
-    it('does not attempt to call a non-function filter/mapper', () => {
-      let filterCalled = false;
-      let mapperCalled = false;
-      const filter = () => {
-        filterCalled = true;
-        return true;
-      };
-      const mapper = (log) => {
-        mapperCalled = true;
-        return log;
-      };
-
-      const evt = {
-        target: {},
-        type: 'test',
-      };
-
-      initPackager([], { on: true });
-      setLogFilter(filter);
-      setLogMapper(mapper);
-
-      packageLog(evt);
-
-      expect(filterCalled).to.equal(true);
-      expect(mapperCalled).to.equal(true);
-
-      setLogFilter('foo');
-      setLogMapper('bar');
-
-      packageLog(evt);
-      expect(logs.length).to.equal(2);
-    });
-  });
-
-  describe('extractTimeFields', () => {
-    it('returns the millisecond and microsecond portions of a timestamp', () => {
-      const timeStamp = 123.456;
-      const fields = { milli: 123, micro: 0.456 };
-      const ret = extractTimeFields(timeStamp);
-
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
+    describe('selectorizePath', () => {
+        it('returns a new array of the same length provided', () => {
+            const arr = [{}, {}];
+            const ret = selectorizePath(arr);
+            expect(ret).to.be.instanceof(Array);
+            expect(ret).to.not.equal(arr);
+            expect(ret.length).to.equal(arr.length);
+        });
     });
-    it('sets micro to 0 when no decimal is present', () => {
-      const timeStamp = 123;
-      const fields = { milli: 123, micro: 0 };
-      const ret = extractTimeFields(timeStamp);
 
-      expect(ret.milli).to.equal(fields.milli);
-      expect(ret.micro).to.equal(fields.micro);
-    });
-    it('always returns an object', () => {
-      const stampVariants = [
-        null,
-        'foobar',
-        { foo: 'bar' },
-        undefined,
-        ['foo', 'bar'],
-        123,
-      ];
-
-      stampVariants.forEach((variant) => {
-        const ret = extractTimeFields(variant);
-        expect(!!ret).to.equal(true);
-        expect(typeof ret).to.equal('object');
-      });
-    });
-  });
-
-  describe('getLocation', () => {
-    it('returns event page location', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            e.pageX = 0;
-            e.pageY = 0;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
-    });
-
-    it('calculates page location if unavailable', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const ele = document.createElement('div');
-          const evt = new window.MouseEvent('click', {
-            'view': window,
-            'bubbles': true,
-            'cancelable': true
-          });
-          document.body.appendChild(ele);
-          ele.addEventListener('click', (e) => {
-            document.documentElement.scrollLeft = 0;
-            document.documentElement.scrollTop = 0;
-            const originalDocument = global.document;
-            global.document = document;
-            expect(getLocation(e)).to.deep.equal({ x: 0, y: 0 });
-            global.document = originalDocument;
-            done();
-          });
-          ele.dispatchEvent(evt);
-        },
-      });
+    describe('getSelector', () => {
+        it('builds a selector', () => {
+            new JSDOM(``)
+            const document = window.document;
+            const element = document.createElement('div');
+            expect(getSelector(element)).to.equal('div');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar');
+            element.removeAttribute('id');
+            element.classList.add('baz');
+            expect(getSelector(element)).to.equal('div.baz');
+            element.id = 'bar';
+            expect(getSelector(element)).to.equal('div#bar.baz');
+        });
     });
 
-    it('fails to null', (done) => {
-      let hadError = false;
-      try {
-        getLocation(null);
-      } catch (e) {
-        hadError = true;
-      }
-      expect(hadError).to.equal(true);
-      done();
-    });
-  });
-
-  describe('selectorizePath', () => {
-    it('returns a new array of the same length provided', (done) => {
-      const arr = [{}, {}];
-      const ret = selectorizePath(arr);
-      expect(ret).to.be.instanceof(Array);
-      expect(ret).to.not.equal(arr);
-      expect(ret.length).to.equal(arr.length);
-      done();
-    });
-  });
-
-  describe('getSelector', () => {
-    it('builds a selector', (done) => {
-      jsdom.env({
-        url, html,
-        done: (err, window) => {
-          const document = window.document;
-          const element = document.createElement('div');
-          expect(getSelector(element)).to.equal('div');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar');
-          element.removeAttribute('id');
-          element.classList.add('baz');
-          expect(getSelector(element)).to.equal('div.baz');
-          element.id = 'bar';
-          expect(getSelector(element)).to.equal('div#bar.baz');
-          done();
-        },
-      });
+    it('identifies window', () => {

Review comment:
       making minor edit here to pull 'identifies window' into describe('getSelector')




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org