Blame view

node_modules/event-emitter/test/all-off.js 736 Bytes
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  'use strict';
  
  var ee = require('../');
  
  module.exports = function (t, a) {
  	var x, count, count2;
  
  	x = ee();
  	count = 0;
  	count2 = 0;
  	x.on('foo', function () {
  		++count;
  	});
  	x.on('foo', function () {
  		++count;
  	});
  	x.on('bar', function () {
  		++count2;
  	});
  	x.on('bar', function () {
  		++count2;
  	});
  	t(x, 'foo');
  	x.emit('foo');
  	x.emit('bar');
  	a(count, 0, "All off: type");
  	a(count2, 2, "All off: ohter type");
  
  	count = 0;
  	count2 = 0;
  	x.on('foo', function () {
  		++count;
  	});
  	x.on('foo', function () {
  		++count;
  	});
  	x.on('bar', function () {
  		++count2;
  	});
  	x.on('bar', function () {
  		++count2;
  	});
  	t(x);
  	x.emit('foo');
  	x.emit('bar');
  	a(count, 0, "All off: type");
  	a(count2, 0, "All off: other type");
  };