Permalink
Browse files

[testcase] allow fast event emitting

  • Loading branch information...
1 parent 2d4cdfc commit c7ba1d800b2d81ecd882af7e66e1b7cdbb42cadc @AndreasMadsen committed Feb 4, 2012
Showing with 25 additions and 5 deletions.
  1. +25 −5 test/abstracts/lisenter.js
View
@@ -31,14 +31,30 @@ module.exports = function (layer) {
requesterProcess.send({what: 'connect'});
});
+ // check listening event now
+ var isListening = false;
+ lisenter.on('listening', function () {
+ isListening = true;
+ });
+
+ // check connection event now
+ var isConnection = false;
+ lisenter.on('connection', function () {
+ isConnection = true;
+ });
+
return [{
// first batch of tests
- 'when ready event is emitted': {
+ 'when listening event is emitted': {
topic: function () {
var self = this;
- lisenter.on('listening', function () {
+ if (isListening) {
self.callback(null, lisenter);
- });
+ } else {
+ lisenter.on('listening', function () {
+ self.callback(null, lisenter);
+ });
+ }
},
'the online state is true': function (error, result) {
@@ -49,9 +65,13 @@ module.exports = function (layer) {
'when connection has been made': {
topic: function () {
var self = this;
- lisenter.on('connection', function () {
+ if (isConnection) {
self.callback(null, lisenter);
- });
+ } else {
+ lisenter.on('connection', function () {
+ self.callback(null, lisenter);
+ });
+ }
},
'connection event will emit': function (error, result) {

0 comments on commit c7ba1d8

Please sign in to comment.