forked from javve/list.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.off.js
39 lines (34 loc) · 1.09 KB
/
test.off.js
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
describe('Off', function() {
var list;
before(function() {
list = fixture.list(['name', 'born'], fixture.all);
});
after(function() {
fixture.removeList();
});
describe('General', function() {
it('should be remove added handler', function(done) {
var updated = function(list) {
expect(list.handlers.updated.length).to.equal(1);
list.off('updated', updated);
expect(list.handlers.updated.length).to.equal(0);
done();
};
list.on('updated', updated);
list.search('jonny');
});
it('should not remove unnamed handlers', function(done) {
var searchComplete = function(list) {
expect(list.handlers.searchComplete.length).to.equal(3);
list.off('searchComplete', function() {});
list.off('searchComplete', searchComplete);
expect(list.handlers.searchComplete.length).to.equal(2);
done();
};
list.on('searchComplete', function() {});
list.on('searchComplete', searchComplete);
list.on('searchComplete', function() {});
list.search('jonny');
});
});
});