UNPKG

1.34 kBJavaScriptView Raw
1'use strict';
2
3var ee = require('../');
4
5module.exports = function (t) {
6 var x, y;
7 return {
8 Any: function (a) {
9 a(t(true), false, "Primitive");
10 a(t({ events: [] }), false, "Other object");
11 a(t(x = ee()), false, "Emitter: empty");
12
13 x.on('test', y = function () {});
14 a(t(x), true, "Emitter: full");
15 x.off('test', y);
16 a(t(x), false, "Emitter: empty but touched");
17 x.once('test', y = function () {});
18 a(t(x), true, "Emitter: full: Once");
19 x.off('test', y);
20 a(t(x), false, "Emitter: empty but touched by once");
21 },
22 Specific: function (a) {
23 a(t(true, 'test'), false, "Primitive");
24 a(t({ events: [] }, 'test'), false, "Other object");
25 a(t(x = ee(), 'test'), false, "Emitter: empty");
26
27 x.on('test', y = function () {});
28 a(t(x, 'test'), true, "Emitter: full");
29 a(t(x, 'foo'), false, "Emitter: full, other event");
30 x.off('test', y);
31 a(t(x, 'test'), false, "Emitter: empty but touched");
32 a(t(x, 'foo'), false, "Emitter: empty but touched, other event");
33
34 x.once('test', y = function () {});
35 a(t(x, 'test'), true, "Emitter: full: Once");
36 a(t(x, 'foo'), false, "Emitter: full: Once, other event");
37 x.off('test', y);
38 a(t(x, 'test'), false, "Emitter: empty but touched by once");
39 a(t(x, 'foo'), false, "Emitter: empty but touched by once, other event");
40 }
41 };
42};