EandrewJones commented on code in PR #453:
URL: https://github.com/apache/flagon-useralejs/pull/453#discussion_r1600154188


##########
test/sendLogs_spec.js:
##########
@@ -94,25 +94,24 @@ describe('sendLogs', () => {
         done();
     });
 
-    it('sends logs on page exit with navigator', () => {
-        const sendBeaconSpy = sinon.spy()
-        global.navigator = {
-            sendBeacon: sendBeaconSpy
-        };
+    it('sends logs on page exit with fetch', () => {
+        const fetchSpy = sinon.spy()
+        global.fetch = fetchSpy
+
         sendOnClose([], {on: true, url: 'test'})
         sendOnClose([{foo: 'bar'}], {on: true, url: 'test'});
         global.window.dispatchEvent(new window.CustomEvent('pagehide'))
-        sinon.assert.calledOnce(sendBeaconSpy)
+        sinon.assert.calledOnce(fetchSpy)
     });
 
     it('does not send logs on page exit when config is off', () => {
-        const sendBeaconSpy = sinon.spy()
-        global.navigator = {
-            sendBeacon: sendBeaconSpy
-        };
-        sendOnClose([{foo: 'bar'}], {on: false, url: 'test'});
-        global.window.dispatchEvent(new window.CustomEvent('pagehide'))
-        sinon.assert.notCalled(sendBeaconSpy)
+        const fetchSpy = new sinon.spy();
+        global.fetch = fetchSpy;
+
+        sendOnClose([{foo: 'baz'}], {on: false, url: 'test'});
+        global.window.dispatchEvent(new window.CustomEvent('pagehide'));
+        // sinon.assert.notCalled(fetchSpy);
+        sinon.assert.callCount(fetchSpy, 1);

Review Comment:
   This test aims to ensure the function is _not_ called. Why is the notCalled 
line commented out and replaced with an assurance that the function _is_ called?
   
   If you needed to change the test behavior to get it to pass, it means there 
is breaking behavior that must be addressed.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@flagon.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@flagon.apache.org
For additional commands, e-mail: notifications-h...@flagon.apache.org

Reply via email to