react 0.3.0 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,9 @@ var test = require('tap').test;
4
4
  var BaseTask = require('../lib/base-task.js');
5
5
 
6
6
  var react = require('../'); // require('react');
7
+ // turn on tracking, optionally obtain EventCollector
8
+ var EventCollector = require('../lib/track-tasks').EventCollector; // require('react/lib/track-tasks');
9
+
7
10
 
8
11
  /**
9
12
  @example
@@ -79,6 +82,7 @@ test('use react() default DSL from module', function (t) {
79
82
  multiply, 'a, b, cb -> err, m',
80
83
  add, 'm, a, cb -> err, s'
81
84
  );
85
+
82
86
 
83
87
  fn(2, 3, function (err, m, s) {
84
88
  t.deepEqual(err, null, 'should not be any error');
@@ -96,10 +100,6 @@ test('use react.selectFirst() default DSL with events', function (t) {
96
100
  function noSuccessNull(a, b, cb) { cb(null, null); } // returns null result
97
101
  function add(a, b, cb) { cb(null, a + b); }
98
102
 
99
- var events = [];
100
- function accumEvents(task) {
101
- events.push(task);
102
- }
103
103
 
104
104
  var fn = react.selectFirst('mySelectFirst', 'a, b, cb -> err, c',
105
105
  noSuccess, 'a, b, cb -> err, c',
@@ -108,16 +108,18 @@ test('use react.selectFirst() default DSL with events', function (t) {
108
108
  noSuccess, 'a, b, cb -> err, c'
109
109
  );
110
110
 
111
- fn.events.on('task.complete', accumEvents);
111
+ var collector = new EventCollector();
112
+ collector.capture(fn, 'task.complete');
112
113
 
113
114
  fn(2, 3, function (err, c) {
114
115
  t.deepEqual(err, null, 'should not be any error');
115
116
  t.equal(c, 5);
117
+ var events = collector.list();
116
118
  t.equal(events.length, 3, 'should have seen two task compl events');
117
- t.equal(events[0].name, 'noSuccess', 'name matches');
118
- t.equal(events[1].name, 'noSuccessNull', 'name matches');
119
- t.equal(events[2].name, 'add', 'name matches');
120
- t.deepEqual(events[2].results, [5], 'results match');
119
+ t.equal(events[0].task.name, 'noSuccess', 'name matches');
120
+ t.equal(events[1].task.name, 'noSuccessNull', 'name matches');
121
+ t.equal(events[2].task.name, 'add', 'name matches');
122
+ t.deepEqual(events[2].task.results, [5], 'results match');
121
123
  t.end();
122
124
  });
123
125
  });