You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2018/12/18 15:00:36 UTC

[cordova-common] branch brodybits-events-updates created (now 8030af1)

This is an automated email from the ASF dual-hosted git repository.

brodybits pushed a change to branch brodybits-events-updates
in repository https://gitbox.apache.org/repos/asf/cordova-common.git.


      at 8030af1  Add Cordova events emit tests

This branch includes the following new commits:

     new 87504de  Explicit Cordova events section in spec
     new 8030af1  Add Cordova events emit tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[cordova-common] 02/02: Add Cordova events emit tests

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brodybits pushed a commit to branch brodybits-events-updates
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit 8030af13b440dc2ffc0b4aafeb4130ee49245368
Author: Christopher J. Brody <ch...@gmail.com>
AuthorDate: Tue Dec 18 09:27:49 2018 -0500

    Add Cordova events emit tests
    
    with other minor Cordova events test updates
    
    Co-authored-by: Christopher J. Brody <ch...@gmail.com>
    Co-authored-by: daserge <v-...@microsoft.com>
---
 spec/events.spec.js | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/spec/events.spec.js b/spec/events.spec.js
index 2fa8453..7209c37 100644
--- a/spec/events.spec.js
+++ b/spec/events.spec.js
@@ -20,28 +20,51 @@
 var events = require('../src/events');
 
 describe('Cordova events', function () {
+    it('Test 001 : should emit events to a listener', function () {
+        var logSpy = jasmine.createSpy('logSpy');
+        events.on('log', logSpy);
+
+        events.emit('log', 'a test message');
+        expect(logSpy).toHaveBeenCalledWith('a test message');
+    });
+
     describe('forwardEventsTo method', function () {
         afterEach(function () {
             events.forwardEventsTo(null);
         });
-        it('Test 001 : should not go to infinite loop when trying to forward to self', function () {
+
+        it('Test 002 : should forward events to another event emitter', function () {
+            var EventEmitter = require('events').EventEmitter;
+            var anotherEventEmitter = new EventEmitter();
+            var logSpy = jasmine.createSpy('logSpy');
+            anotherEventEmitter.on('log', logSpy);
+
+            events.forwardEventsTo(anotherEventEmitter);
+            events.emit('log', 'forwarding test message');
+            expect(logSpy).toHaveBeenCalledWith('forwarding test message');
+        });
+
+        it('Test 003 : should not go to infinite loop when trying to forward to self', function () {
             expect(function () {
                 events.forwardEventsTo(events);
                 events.emit('log', 'test message');
             }).not.toThrow();
         });
-        it('Test 002 : should reset forwarding after trying to forward to self', function () {
+
+        it('Test 004 : should reset forwarding after trying to forward to self', function () {
             var EventEmitter = require('events').EventEmitter;
             var anotherEventEmitter = new EventEmitter();
             var logSpy = jasmine.createSpy('logSpy');
             anotherEventEmitter.on('log', logSpy);
 
+            // should forward events to another event emitter at this point
             events.forwardEventsTo(anotherEventEmitter);
             events.emit('log', 'test message #1');
-            expect(logSpy).toHaveBeenCalled();
+            expect(logSpy).toHaveBeenCalledWith('test message #1');
 
             logSpy.calls.reset();
 
+            // should *not* forward events to another event emitter at this point
             events.forwardEventsTo(events);
             events.emit('log', 'test message #2');
             expect(logSpy).not.toHaveBeenCalled();


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


[cordova-common] 01/02: Explicit Cordova events section in spec

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brodybits pushed a commit to branch brodybits-events-updates
in repository https://gitbox.apache.org/repos/asf/cordova-common.git

commit 87504def8d2dea9dbbd73aec34f6d22e324b50a8
Author: Christopher J. Brody <ch...@gmail.com>
AuthorDate: Tue Dec 18 08:54:46 2018 -0500

    Explicit Cordova events section in spec
    
    with forwardEventsTo method section indented
---
 spec/events.spec.js | 46 ++++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/spec/events.spec.js b/spec/events.spec.js
index 08a5498..2fa8453 100644
--- a/spec/events.spec.js
+++ b/spec/events.spec.js
@@ -19,30 +19,32 @@
 
 var events = require('../src/events');
 
-describe('forwardEventsTo method', function () {
-    afterEach(function () {
-        events.forwardEventsTo(null);
-    });
-    it('Test 001 : should not go to infinite loop when trying to forward to self', function () {
-        expect(function () {
-            events.forwardEventsTo(events);
-            events.emit('log', 'test message');
-        }).not.toThrow();
-    });
-    it('Test 002 : should reset forwarding after trying to forward to self', function () {
-        var EventEmitter = require('events').EventEmitter;
-        var anotherEventEmitter = new EventEmitter();
-        var logSpy = jasmine.createSpy('logSpy');
-        anotherEventEmitter.on('log', logSpy);
+describe('Cordova events', function () {
+    describe('forwardEventsTo method', function () {
+        afterEach(function () {
+            events.forwardEventsTo(null);
+        });
+        it('Test 001 : should not go to infinite loop when trying to forward to self', function () {
+            expect(function () {
+                events.forwardEventsTo(events);
+                events.emit('log', 'test message');
+            }).not.toThrow();
+        });
+        it('Test 002 : should reset forwarding after trying to forward to self', function () {
+            var EventEmitter = require('events').EventEmitter;
+            var anotherEventEmitter = new EventEmitter();
+            var logSpy = jasmine.createSpy('logSpy');
+            anotherEventEmitter.on('log', logSpy);
 
-        events.forwardEventsTo(anotherEventEmitter);
-        events.emit('log', 'test message #1');
-        expect(logSpy).toHaveBeenCalled();
+            events.forwardEventsTo(anotherEventEmitter);
+            events.emit('log', 'test message #1');
+            expect(logSpy).toHaveBeenCalled();
 
-        logSpy.calls.reset();
+            logSpy.calls.reset();
 
-        events.forwardEventsTo(events);
-        events.emit('log', 'test message #2');
-        expect(logSpy).not.toHaveBeenCalled();
+            events.forwardEventsTo(events);
+            events.emit('log', 'test message #2');
+            expect(logSpy).not.toHaveBeenCalled();
+        });
     });
 });


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