forked from OscarGodson/EpicEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.removeListener.js
More file actions
63 lines (53 loc) · 1.43 KB
/
test.removeListener.js
File metadata and controls
63 lines (53 loc) · 1.43 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*global createContainer:false, removeContainer:false, rnd:false */
describe('.removeListener(event, [handler])', function () {
var testEl
, id
, editor
, eventFired
, baz
, qux
, count;
beforeEach(function (done) {
id = rnd();
testEl = createContainer(id);
editor = new EpicEditor({ basePath: '/epiceditor/', container: testEl }).load();
eventFired = false;
count = 0;
editor.on('foo', function () {
eventFired = true;
});
baz = function () {
count++;
};
qux = function () {
count++;
};
editor.on('bar', baz);
editor.on('bar', qux);
done();
});
afterEach(function (done) {
editor.unload();
removeContainer(id);
done();
});
it('should initially fire the foo event', function () {
editor.emit('foo');
expect(eventFired).to.be(true);
});
it('should not call the handler if it has been removed without a handler param', function () {
editor.removeListener('foo');
editor.emit('foo');
expect(eventFired).to.be(false);
});
it('should only remove the passed named handler for a given event', function () {
editor.removeListener('bar', baz);
editor.emit('bar');
expect(count).to.be(1);
});
it('should remove all named handlers for a given event when that parameter is NOT passed', function () {
editor.removeListener('bar');
editor.emit('bar');
expect(count).to.be(0);
});
});