Skip to content
Permalink
Browse files
Explicit Cordova events section in spec
with forwardEventsTo method section indented
  • Loading branch information
Christopher J. Brody committed Dec 18, 2018
1 parent 6667cfc commit 87504def8d2dea9dbbd73aec34f6d22e324b50a8
Showing 1 changed file with 24 additions and 22 deletions.
@@ -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();
});
});
});

0 comments on commit 87504de

Please sign in to comment.