forked from jashkenas/backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speed.js
45 lines (32 loc) · 1.05 KB
/
speed.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
43
44
45
(function(){
var object = {};
_.extend(object, Backbone.Events);
var fn = function(){};
JSLitmus.test('Events: bind + unbind', function() {
object.bind("event", fn);
object.unbind("event", fn);
});
object.bind('test:trigger', fn);
JSLitmus.test('Events: trigger', function() {
object.trigger('test:trigger');
});
object.bind('test:trigger2', fn);
object.bind('test:trigger2', fn);
JSLitmus.test('Events: trigger 2, passing 5 args', function() {
object.trigger('test:trigger2', 1, 2, 3, 4, 5);
});
var model = new Backbone.Model;
JSLitmus.test('Model: set Math.random()', function() {
model.set({number: Math.random()});
});
var eventModel = new Backbone.Model;
eventModel.bind('change', fn);
JSLitmus.test('Model: set rand() with an event', function() {
eventModel.set({number: Math.random()});
});
var keyModel = new Backbone.Model;
keyModel.bind('change:number', fn);
JSLitmus.test('Model: set rand() with an attribute observer', function() {
keyModel.set({number: Math.random()});
});
})();