##// END OF EJS Templates
Adding basic tests for keyboard.js
Brian E. Granger -
Show More
@@ -0,0 +1,49 b''
1
2
3 var normalized_shortcuts = [
4 'ctrl+shift+m',
5 'alt+meta+p',
6 ];
7
8 var to_normalize = [
9 ['shift+%', 'shift+5'],
10 ['ShiFT+MeTa+CtRl+AlT+m', 'alt+ctrl+meta+shift+m'],
11 ];
12
13 var unshifted = "` 1 2 3 4 5 6 7 8 9 0 - = q w e r t y u i o p [ ] \\ a s d f g h j k l ; ' z x c v b n m , . /";
14 // shifted = '~ ! @ # $ % ^ & * ( ) _ + Q W E R T Y U I O P { } | A S D F G H J K L : " Z X C V B N M < > ?';
15
16 casper.notebook_test(function () {
17
18 this.then(function () {
19 this.each(unshifted.split(' '), function (self, item) {
20 var result = this.evaluate(function (sc) {
21 var e = IPython.keyboard.shortcut_to_event(sc);
22 var sc2 = IPython.keyboard.event_to_shortcut(e);
23 return sc2;
24 }, item);
25 this.test.assertEquals(result, item, 'Shortcut to event roundtrip: '+item);
26 });
27 });
28
29 this.then(function () {
30 this.each(to_normalize, function (self, item) {
31 var result = this.evaluate(function (pair) {
32 return IPython.keyboard.normalize_shortcut(pair[0]);
33 }, item);
34 this.test.assertEquals(result, item[1], 'Normalize shortcut: '+item[0]);
35 });
36 })
37
38 this.then(function () {
39 this.each(normalized_shortcuts, function (self, item) {
40 var result = this.evaluate(function (sc) {
41 var e = IPython.keyboard.shortcut_to_event(sc);
42 var sc2 = IPython.keyboard.event_to_shortcut(e);
43 return sc2;
44 }, item);
45 this.test.assertEquals(result, item, 'Shortcut to event roundtrip: '+item);
46 });
47 });
48
49 }); No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now