1 | 'use strict';
|
2 |
|
3 | var ee = require('../');
|
4 |
|
5 | module.exports = function (t, a) {
|
6 | var x = {}, y = {}, z = {}, count, count2, count3, pipe;
|
7 |
|
8 | ee(x);
|
9 | x = Object.create(x);
|
10 | ee(y);
|
11 | ee(z);
|
12 |
|
13 | count = 0;
|
14 | count2 = 0;
|
15 | count3 = 0;
|
16 | x.on('foo', function () {
|
17 | ++count;
|
18 | });
|
19 | y.on('foo', function () {
|
20 | ++count2;
|
21 | });
|
22 | z.on('foo', function () {
|
23 | ++count3;
|
24 | });
|
25 |
|
26 | x.emit('foo');
|
27 | a(count, 1, "Pre pipe, x");
|
28 | a(count2, 0, "Pre pipe, y");
|
29 | a(count3, 0, "Pre pipe, z");
|
30 |
|
31 | pipe = t(x, y);
|
32 | x.emit('foo');
|
33 | a(count, 2, "Post pipe, x");
|
34 | a(count2, 1, "Post pipe, y");
|
35 | a(count3, 0, "Post pipe, z");
|
36 |
|
37 | y.emit('foo');
|
38 | a(count, 2, "Post pipe, on y, x");
|
39 | a(count2, 2, "Post pipe, on y, y");
|
40 | a(count3, 0, "Post pipe, on y, z");
|
41 |
|
42 | t(x, z);
|
43 | x.emit('foo');
|
44 | a(count, 3, "Post pipe z, x");
|
45 | a(count2, 3, "Post pipe z, y");
|
46 | a(count3, 1, "Post pipe z, z");
|
47 |
|
48 | pipe.close();
|
49 | x.emit('foo');
|
50 | a(count, 4, "Close pipe y, x");
|
51 | a(count2, 3, "Close pipe y, y");
|
52 | a(count3, 2, "Close pipe y, z");
|
53 | };
|