This repository has been archived by the owner on Jan 5, 2021. It is now read-only.
/
manager.js
69 lines (64 loc) · 1.72 KB
/
manager.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
module("Manager", {
setup: function() {
return this.manager = new Manager({
$container: $("#application"),
events: {
manager_init: new Event
},
page: {
current_space: {
match: function() {
return true;
},
hit: function() {
return null;
},
miss: function() {
return null;
}
}
},
keyboard: {
selectKey: __bind(function(charCode, keyCode) {
return this.selected_key = keyCode;
}, this),
deselectKey: __bind(function() {
return this.selected_key = null;
}, this)
}
});
}
});
test("#processKeyPress does nothing for backspace", function() {
return equal(this.manager.processKeyPress({
keyCode: 8
}), null);
});
test("keydown within document deligates to keyboard", function() {
var e;
e = $.Event("keydown");
e.keyCode = 13;
($(document)).trigger(e);
return equal(this.selected_key, 13, 'keyboard called with keyCode');
});
test("#precessKeyDown sends backspace to current space", function() {
this.manager.base.page.current_space.match = __bind(function(code) {
return this.space_code = code;
}, this);
this.manager.processKeyDown({
keyCode: 8,
preventDefault: function() {
return null;
}
});
return equal(this.space_code, 8);
});
test("keyup within document deligates to keyboard", function() {
var e;
this.selected_key = 8;
e = $.Event("keyup");
e.keyCode = this.selected_key;
($(document)).trigger(e);
return equal(this.selected_key, null, 'keyboard called with keyCode');
});