From f6da96a7577bd831134ee8e221833baa0ad20c8a Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Wed, 16 Aug 2017 22:21:26 -0700 Subject: [PATCH 1/2] guard window and document --- client/util.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/util.js b/client/util.js index 06cb27a..8e2cb7c 100644 --- a/client/util.js +++ b/client/util.js @@ -105,11 +105,14 @@ export function promiseDebounce(method, interval) { } export let windowReady = new ZalgoPromise(resolve => { - if (document.readyState === 'complete') { + // guard document, and window.addEventListener for JSC (react-native) + if (typeof(document) !== 'undefined' && document.readyState === 'complete') { resolve(); } - - window.addEventListener('load', resolve); + + if(window.addEventListener) { + window.addEventListener ('load', resolve); + } }); export function safeInterval(method, time) { From 58e70426a3ec6052f3caaf871cea88da48f9f82a Mon Sep 17 00:00:00 2001 From: Derek Anderson Date: Wed, 16 Aug 2017 22:50:40 -0700 Subject: [PATCH 2/2] fix test not running --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index bbcead5..fd88373 100644 --- a/test/test.js +++ b/test/test.js @@ -19,8 +19,8 @@ describe('xcomponent tests', function() { var logEndpoint = $mockEndpoint.register({ method: 'POST', uri: '/test/api/log', - handler: function(data) { - var hasLog = data.events.some(event => event.event === 'hello_world' && event.level === 'info'); + handler: function(req) { + var hasLog = req.data.events.some(event => event.event === 'hello_world' && event.level === 'info'); assert.isTrue(hasLog, 'Expected posted payload to contain logged log') } });