-
-
Notifications
You must be signed in to change notification settings - Fork 644
/
Copy pathon.js
42 lines (35 loc) · 1.03 KB
/
on.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
40
41
42
(function (window) {
var Muuri = window.Muuri;
QUnit.module('Grid methods');
QUnit.test('on: should return the instance', function (assert) {
assert.expect(1);
var container = utils.createGridElements();
var grid = new Muuri(container);
var teardown = function () {
grid.destroy();
container.parentNode.removeChild(container);
};
assert.strictEqual(
grid.on('foo', function () {}),
grid
);
teardown();
});
QUnit.test('on: should bind an event listener', function (assert) {
assert.expect(1);
var container = utils.createGridElements();
var grid = new Muuri(container);
var calls = 0;
var callback = function () {
++calls;
};
var teardown = function () {
grid.destroy();
container.parentNode.removeChild(container);
};
grid.on('synchronize', callback);
grid.synchronize().synchronize().synchronize();
assert.strictEqual(calls, 3, 'should execute the listeners when event is emitted');
teardown();
});
})(this);