##// END OF EJS Templates
Cleaned up test names and locations.
Jonathan Frederic -
Show More
@@ -0,0 +1,49 b''
1
2 // Test
3 casper.notebook_test(function () {
4 var a = 'print("a")';
5 var index = this.append_cell(a);
6 this.execute_cell_then(index);
7
8 var b = 'print("b")';
9 index = this.append_cell(b);
10 this.execute_cell_then(index);
11
12 var c = 'print("c")';
13 index = this.append_cell(c);
14 this.execute_cell_then(index);
15
16 this.then(function () {
17
18 // Up and down in command mode
19 this.select_cell(3);
20 this.trigger_keydown('j');
21 this.validate_notebook_state('j at end of notebook', 'command', 3);
22 this.trigger_keydown('down');
23 this.validate_notebook_state('down at end of notebook', 'command', 3);
24 this.trigger_keydown('up');
25 this.validate_notebook_state('up', 'command', 2);
26 this.select_cell(0);
27 this.validate_notebook_state('select 0', 'command', 0);
28 this.trigger_keydown('k');
29 this.validate_notebook_state('k at top of notebook', 'command', 0);
30 this.trigger_keydown('up');
31 this.validate_notebook_state('up at top of notebook', 'command', 0);
32 this.trigger_keydown('down');
33 this.validate_notebook_state('down', 'command', 1);
34
35 // Up and down in edit mode
36 this.click_cell_editor(3);
37 this.validate_notebook_state('click cell 3', 'edit', 3);
38 this.trigger_keydown('down');
39 this.validate_notebook_state('down at end of notebook', 'edit', 3);
40 this.trigger_keydown('up');
41 this.validate_notebook_state('up', 'edit', 2);
42 this.click_cell_editor(0);
43 this.validate_notebook_state('click 0', 'edit', 0);
44 this.trigger_keydown('up');
45 this.validate_notebook_state('up at top of notebook', 'edit', 0);
46 this.trigger_keydown('down');
47 this.validate_notebook_state('down', 'edit', 1);
48 });
49 });
@@ -0,0 +1,27 b''
1
2 // Test
3 casper.notebook_test(function () {
4 var a = 'print("a")';
5 var index = this.append_cell(a);
6 this.execute_cell_then(index);
7
8 var b = 'print("b")';
9 index = this.append_cell(b);
10 this.execute_cell_then(index);
11
12 var c = 'print("c")';
13 index = this.append_cell(c);
14 this.execute_cell_then(index);
15
16 this.then(function () {
17 // Cell insertion
18 this.select_cell(2);
19 this.trigger_keydown('a'); // Creates one cell
20 this.test.assertEquals(this.get_cell_text(2), '', 'a; New cell 2 text is empty');
21 this.validate_notebook_state('a', 'command', 2);
22 this.trigger_keydown('b'); // Creates one cell
23 this.test.assertEquals(this.get_cell_text(2), '', 'b; Cell 2 text is still empty');
24 this.test.assertEquals(this.get_cell_text(3), '', 'b; New cell 3 text is empty');
25 this.validate_notebook_state('b', 'command', 3);
26 });
27 }); No newline at end of file
@@ -0,0 +1,28 b''
1 // Test keyboard shortcuts that change the cell's mode.
2
3 // Test
4 casper.notebook_test(function () {
5 this.then(function () {
6 // Cell mode change
7 this.select_cell(0);
8 this.trigger_keydown('esc','r');
9 this.test.assertEquals(this.get_cell(0).cell_type, 'raw', 'r; cell is raw');
10 this.trigger_keydown('1');
11 this.test.assertEquals(this.get_cell(0).cell_type, 'heading', '1; cell is heading');
12 this.test.assertEquals(this.get_cell(0).level, 1, '1; cell is level 1 heading');
13 this.trigger_keydown('2');
14 this.test.assertEquals(this.get_cell(0).level, 2, '2; cell is level 2 heading');
15 this.trigger_keydown('3');
16 this.test.assertEquals(this.get_cell(0).level, 3, '3; cell is level 3 heading');
17 this.trigger_keydown('4');
18 this.test.assertEquals(this.get_cell(0).level, 4, '4; cell is level 4 heading');
19 this.trigger_keydown('5');
20 this.test.assertEquals(this.get_cell(0).level, 5, '5; cell is level 5 heading');
21 this.trigger_keydown('6');
22 this.test.assertEquals(this.get_cell(0).level, 6, '6; cell is level 6 heading');
23 this.trigger_keydown('m');
24 this.test.assertEquals(this.get_cell(0).cell_type, 'markdown', 'm; cell is markdown');
25 this.trigger_keydown('y');
26 this.test.assertEquals(this.get_cell(0).cell_type, 'code', 'y; cell is code');
27 });
28 }); No newline at end of file
@@ -0,0 +1,55 b''
1
2
3 // Test
4 casper.notebook_test(function () {
5 var a = 'print("a")';
6 var index = this.append_cell(a);
7 this.execute_cell_then(index);
8
9 var b = 'print("b")';
10 index = this.append_cell(b);
11 this.execute_cell_then(index);
12
13 var c = 'print("c")';
14 index = this.append_cell(c);
15 this.execute_cell_then(index);
16
17 this.then(function () {
18 // Copy/paste/cut
19 var num_cells = this.get_cells_length();
20 this.test.assertEquals(this.get_cell_text(1), a, 'Verify that cell 1 is a');
21 this.select_cell(1);
22 this.trigger_keydown('x'); // Cut
23 this.validate_notebook_state('x', 'command', 1);
24 this.test.assertEquals(this.get_cells_length(), num_cells-1, 'Verify that a cell was removed.');
25 this.test.assertEquals(this.get_cell_text(1), b, 'Verify that cell 2 is now where cell 1 was.');
26 this.select_cell(2);
27 this.trigger_keydown('v'); // Paste
28 this.validate_notebook_state('v', 'command', 3); // Selection should move to pasted cell, below current cell.
29 this.test.assertEquals(this.get_cell_text(3), a, 'Verify that cell 3 has the cut contents.');
30 this.test.assertEquals(this.get_cells_length(), num_cells, 'Verify a the cell was added.');
31 this.trigger_keydown('v'); // Paste
32 this.validate_notebook_state('v', 'command', 4); // Selection should move to pasted cell, below current cell.
33 this.test.assertEquals(this.get_cell_text(4), a, 'Verify that cell 4 has the cut contents.');
34 this.test.assertEquals(this.get_cells_length(), num_cells+1, 'Verify a the cell was added.');
35 this.select_cell(1);
36 this.trigger_keydown('c'); // Copy
37 this.validate_notebook_state('c', 'command', 1);
38 this.test.assertEquals(this.get_cell_text(1), b, 'Verify that cell 1 is b');
39 this.select_cell(2);
40 this.trigger_keydown('c'); // Copy
41 this.validate_notebook_state('c', 'command', 2);
42 this.test.assertEquals(this.get_cell_text(2), c, 'Verify that cell 2 is c');
43 this.select_cell(4);
44 this.trigger_keydown('v'); // Paste
45 this.validate_notebook_state('v', 'command', 5);
46 this.test.assertEquals(this.get_cell_text(2), c, 'Verify that cell 2 still has the copied contents.');
47 this.test.assertEquals(this.get_cell_text(5), c, 'Verify that cell 5 has the copied contents.');
48 this.test.assertEquals(this.get_cells_length(), num_cells+2, 'Verify a the cell was added.');
49 this.select_cell(0);
50 this.trigger_keydown('shift+v'); // Paste
51 this.validate_notebook_state('shift+v', 'command', 0);
52 this.test.assertEquals(this.get_cell_text(0), c, 'Verify that cell 0 has the copied contents.');
53 this.test.assertEquals(this.get_cells_length(), num_cells+3, 'Verify a the cell was added.');
54 });
55 }); No newline at end of file
@@ -0,0 +1,72 b''
1 // Test keyboard invoked execution.
2
3 // Test
4 casper.notebook_test(function () {
5 var a = 'print("a")';
6 var index = this.append_cell(a);
7 this.execute_cell_then(index);
8
9 var b = 'print("b")';
10 index = this.append_cell(b);
11 this.execute_cell_then(index);
12
13 var c = 'print("c")';
14 index = this.append_cell(c);
15 this.execute_cell_then(index);
16
17 this.then(function () {
18
19 // shift+enter
20 // last cell in notebook
21 var base_index = 3;
22 this.select_cell(base_index);
23 this.trigger_keydown('shift+enter'); // Creates one cell
24 this.validate_notebook_state('shift+enter (no cell below)', 'edit', base_index + 1);
25 // not last cell in notebook & starts in edit mode
26 this.click_cell_editor(base_index);
27 this.validate_notebook_state('click cell ' + base_index, 'edit', base_index);
28 this.trigger_keydown('shift+enter');
29 this.validate_notebook_state('shift+enter (cell exists below)', 'command', base_index + 1);
30 // starts in command mode
31 this.trigger_keydown('k');
32 this.validate_notebook_state('k in comand mode', 'command', base_index);
33 this.trigger_keydown('shift+enter');
34 this.validate_notebook_state('shift+enter (start in command mode)', 'command', base_index + 1);
35
36 // ctrl+enter
37 // last cell in notebook
38 base_index++;
39 this.trigger_keydown('ctrl+enter');
40 this.validate_notebook_state('ctrl+enter (no cell below)', 'command', base_index);
41 // not last cell in notebook & starts in edit mode
42 this.click_cell_editor(base_index-1);
43 this.validate_notebook_state('click cell ' + (base_index-1), 'edit', base_index-1);
44 this.trigger_keydown('ctrl+enter');
45 this.validate_notebook_state('ctrl+enter (cell exists below)', 'command', base_index-1);
46 // starts in command mode
47 this.trigger_keydown('j');
48 this.validate_notebook_state('j in comand mode', 'command', base_index);
49 this.trigger_keydown('ctrl+enter');
50 this.validate_notebook_state('ctrl+enter (start in command mode)', 'command', base_index);
51
52 // alt+enter
53 // last cell in notebook
54 this.trigger_keydown('alt+enter'); // Creates one cell
55 this.validate_notebook_state('alt+enter (no cell below)', 'edit', base_index + 1);
56 // not last cell in notebook & starts in edit mode
57 this.click_cell_editor(base_index);
58 this.validate_notebook_state('click cell ' + base_index, 'edit', base_index);
59 this.trigger_keydown('alt+enter'); // Creates one cell
60 this.validate_notebook_state('alt+enter (cell exists below)', 'edit', base_index + 1);
61 // starts in command mode
62 this.trigger_keydown('esc', 'k');
63 this.validate_notebook_state('k in comand mode', 'command', base_index);
64 this.trigger_keydown('alt+enter'); // Creates one cell
65 this.validate_notebook_state('alt+enter (start in command mode)', 'edit', base_index + 1);
66
67 // Notebook will now have 8 cells, the index of the last cell will be 7.
68 this.test.assertEquals(this.get_cells_length(), 8, '*-enter commands added cells where needed.');
69 this.select_cell(7);
70 this.validate_notebook_state('click cell ' + 7 + ' and esc', 'command', 7);
71 });
72 }); No newline at end of file
@@ -0,0 +1,39 b''
1
2 // Test
3 casper.notebook_test(function () {
4 var a = 'print("a")';
5 var index = this.append_cell(a);
6 this.execute_cell_then(index);
7
8 this.then(function () {
9 // Markdown rendering / unredering
10 this.select_cell(1);
11 this.validate_notebook_state('select 1', 'command', 1);
12 this.trigger_keydown('m');
13 this.test.assertEquals(this.get_cell(1).cell_type, 'markdown', 'm; cell is markdown');
14 this.test.assertEquals(this.get_cell(1).rendered, false, 'm; cell is rendered');
15 this.trigger_keydown('enter');
16 this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
17 this.validate_notebook_state('enter', 'edit', 1);
18 this.trigger_keydown('ctrl+enter');
19 this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl+enter; cell is rendered');
20 this.validate_notebook_state('enter', 'command', 1);
21 this.trigger_keydown('enter');
22 this.test.assertEquals(this.get_cell(1).rendered, false, 'enter; cell is unrendered');
23 this.select_cell(0);
24 this.test.assertEquals(this.get_cell(1).rendered, false, 'select 0; cell 1 is still unrendered');
25 this.validate_notebook_state('select 0', 'command', 0);
26 this.select_cell(1);
27 this.validate_notebook_state('select 1', 'command', 1);
28 this.trigger_keydown('ctrl+enter');
29 this.test.assertEquals(this.get_cell(1).rendered, true, 'ctrl+enter; cell is rendered');
30 this.select_cell(0);
31 this.validate_notebook_state('select 0', 'command', 0);
32 this.trigger_keydown('shift+enter');
33 this.validate_notebook_state('shift+enter', 'command', 1);
34 this.test.assertEquals(this.get_cell(1).rendered, true, 'shift+enter; cell is rendered');
35 this.trigger_keydown('shift+enter'); // Creates one cell
36 this.validate_notebook_state('shift+enter', 'edit', 2);
37 this.test.assertEquals(this.get_cell(1).rendered, true, 'shift+enter; cell is rendered');
38 });
39 }); No newline at end of file
@@ -0,0 +1,21 b''
1
2 // Test
3 casper.notebook_test(function () {
4 this.then(function () {
5 // Split and merge cells
6 this.select_cell(0);
7 this.trigger_keydown('a', 'enter'); // Create cell above and enter edit mode.
8 this.validate_notebook_state('a, enter', 'edit', 0);
9 this.set_cell_text(0, 'abcd');
10 this.set_cell_editor_cursor(0, 0, 2);
11 this.test.assertEquals(this.get_cell_text(0), 'abcd', 'Verify that cell 0 has the new contents.');
12 this.trigger_keydown('alt+-'); // Split
13 this.test.assertEquals(this.get_cell_text(0), 'ab', 'split; Verify that cell 0 has the first half.');
14 this.test.assertEquals(this.get_cell_text(1), 'cd', 'split; Verify that cell 1 has the second half.');
15 this.validate_notebook_state('split', 'edit', 1);
16 this.select_cell(0); // Move up to cell 0
17 this.trigger_keydown('shift+m'); // Merge
18 this.validate_notebook_state('merge', 'command', 0);
19 this.test.assertEquals(this.get_cell_text(0), 'ab\ncd', 'merge; Verify that cell 0 has the merged contents.');
20 });
21 }); No newline at end of file
@@ -0,0 +1,25 b''
1
2 // Test
3 casper.notebook_test(function () {
4 var a = 'print("a")';
5 var index = this.append_cell(a);
6 this.execute_cell_then(index);
7
8 var b = 'print("b")';
9 index = this.append_cell(b);
10 this.execute_cell_then(index);
11
12 this.then(function () {
13 // Cell movement ( ctrl+(k or j) )
14 this.select_cell(2);
15 this.test.assertEquals(this.get_cell_text(2), b, 'select 2; Cell 2 text is correct');
16 this.trigger_keydown('ctrl+k'); // Move cell 2 up one
17 this.test.assertEquals(this.get_cell_text(1), b, 'ctrl+k; Cell 1 text is correct');
18 this.test.assertEquals(this.get_cell_text(2), a, 'ctrl+k; Cell 2 text is correct');
19 this.validate_notebook_state('ctrl+k', 'command', 1);
20 this.trigger_keydown('ctrl+j'); // Move cell 1 down one
21 this.test.assertEquals(this.get_cell_text(1), a, 'ctrl+j; Cell 1 text is correct');
22 this.test.assertEquals(this.get_cell_text(2), b, 'ctrl+j; Cell 2 text is correct');
23 this.validate_notebook_state('ctrl+j', 'command', 2);
24 });
25 }); No newline at end of file
@@ -15,7 +15,6 b' casper.notebook_test(function () {'
15 this.execute_cell_then(index);
15 this.execute_cell_then(index);
16
16
17 this.then(function () {
17 this.then(function () {
18 this.print_log();
19 this.validate_notebook_state('initial state', 'edit', 0);
18 this.validate_notebook_state('initial state', 'edit', 0);
20 this.trigger_keydown('esc');
19 this.trigger_keydown('esc');
21 this.validate_notebook_state('esc', 'command', 0);
20 this.validate_notebook_state('esc', 'command', 0);
@@ -62,83 +61,10 b' casper.notebook_test(function () {'
62 this.click_cell_editor(3);
61 this.click_cell_editor(3);
63 this.validate_notebook_state('click cell 3', 'edit', 3);
62 this.validate_notebook_state('click cell 3', 'edit', 3);
64
63
65 // shift+enter
66 // last cell in notebook
67 var base_index = 3;
68 this.trigger_keydown('shift+enter'); // Creates one cell
69 this.validate_notebook_state('shift+enter (no cell below)', 'edit', base_index + 1);
70 // not last cell in notebook & starts in edit mode
71 this.click_cell_editor(base_index);
72 this.validate_notebook_state('click cell ' + base_index, 'edit', base_index);
73 this.trigger_keydown('shift+enter');
74 this.validate_notebook_state('shift+enter (cell exists below)', 'command', base_index + 1);
75 // starts in command mode
76 this.trigger_keydown('k');
77 this.validate_notebook_state('k in comand mode', 'command', base_index);
78 this.trigger_keydown('shift+enter');
79 this.validate_notebook_state('shift+enter (start in command mode)', 'command', base_index + 1);
80
81 // ctrl+enter
82 // last cell in notebook
83 base_index++;
84 this.trigger_keydown('ctrl+enter');
85 this.validate_notebook_state('ctrl+enter (no cell below)', 'command', base_index);
86 // not last cell in notebook & starts in edit mode
87 this.click_cell_editor(base_index-1);
88 this.validate_notebook_state('click cell ' + (base_index-1), 'edit', base_index-1);
89 this.trigger_keydown('ctrl+enter');
90 this.validate_notebook_state('ctrl+enter (cell exists below)', 'command', base_index-1);
91 // starts in command mode
92 this.trigger_keydown('j');
93 this.validate_notebook_state('j in comand mode', 'command', base_index);
94 this.trigger_keydown('ctrl+enter');
95 this.validate_notebook_state('ctrl+enter (start in command mode)', 'command', base_index);
96
97 // alt+enter
98 // last cell in notebook
99 this.trigger_keydown('alt+enter'); // Creates one cell
100 this.validate_notebook_state('alt+enter (no cell below)', 'edit', base_index + 1);
101 // not last cell in notebook & starts in edit mode
102 this.click_cell_editor(base_index);
103 this.validate_notebook_state('click cell ' + base_index, 'edit', base_index);
104 this.trigger_keydown('alt+enter'); // Creates one cell
105 this.validate_notebook_state('alt+enter (cell exists below)', 'edit', base_index + 1);
106 // starts in command mode
107 this.trigger_keydown('esc', 'k');
108 this.validate_notebook_state('k in comand mode', 'command', base_index);
109 this.trigger_keydown('alt+enter'); // Creates one cell
110 this.validate_notebook_state('alt+enter (start in command mode)', 'edit', base_index + 1);
111
112 // Notebook will now have 8 cells, the index of the last cell will be 7.
113 this.test.assertEquals(this.get_cells_length(), 8, '*-enter commands added cells where needed.');
114 this.select_cell(7);
115 this.validate_notebook_state('click cell ' + 7 + ' and esc', 'command', 7);
116
117 // Cell mode change
118 this.trigger_keydown('r');
119 this.test.assertEquals(this.get_cell(7).cell_type, 'raw', 'r; cell is raw');
120 this.trigger_keydown('1');
121 this.test.assertEquals(this.get_cell(7).cell_type, 'heading', '1; cell is heading');
122 this.test.assertEquals(this.get_cell(7).level, 1, '1; cell is level 1 heading');
123 this.trigger_keydown('2');
124 this.test.assertEquals(this.get_cell(7).level, 2, '2; cell is level 2 heading');
125 this.trigger_keydown('3');
126 this.test.assertEquals(this.get_cell(7).level, 3, '3; cell is level 3 heading');
127 this.trigger_keydown('4');
128 this.test.assertEquals(this.get_cell(7).level, 4, '4; cell is level 4 heading');
129 this.trigger_keydown('5');
130 this.test.assertEquals(this.get_cell(7).level, 5, '5; cell is level 5 heading');
131 this.trigger_keydown('6');
132 this.test.assertEquals(this.get_cell(7).level, 6, '6; cell is level 6 heading');
133 this.trigger_keydown('m');
134 this.test.assertEquals(this.get_cell(7).cell_type, 'markdown', 'm; cell is markdown');
135 this.trigger_keydown('y');
136 this.test.assertEquals(this.get_cell(7).cell_type, 'code', 'y; cell is code');
137
138 // Cell deletion
64 // Cell deletion
139 this.trigger_keydown('d', 'd');
65 this.trigger_keydown('esc', 'd', 'd');
140 this.test.assertEquals(this.get_cells_length(), 7, 'dd actually deletes a cell');
66 this.test.assertEquals(this.get_cells_length(), 3, 'dd actually deletes a cell');
141 this.validate_notebook_state('dd', 'command', 6);
67 this.validate_notebook_state('dd', 'command', 2);
142
68
143 // Make sure that if the time between d presses is too long, nothing gets removed.
69 // Make sure that if the time between d presses is too long, nothing gets removed.
144 this.trigger_keydown('d');
70 this.trigger_keydown('d');
@@ -146,140 +72,7 b' casper.notebook_test(function () {'
146 this.wait(1000);
72 this.wait(1000);
147 this.then(function () {
73 this.then(function () {
148 this.trigger_keydown('d');
74 this.trigger_keydown('d');
149 this.test.assertEquals(this.get_cells_length(), 7, "d, 1 second wait, d doesn't delete a cell");
75 this.test.assertEquals(this.get_cells_length(), 3, "d, 1 second wait, d doesn't delete a cell");
150 this.validate_notebook_state('d, 1 second wait, d', 'command', 6);
76 this.validate_notebook_state('d, 1 second wait, d', 'command', 2);
151
152 // Up and down in command mode
153 this.trigger_keydown('j');
154 this.validate_notebook_state('j at end of notebook', 'command', 6);
155 this.trigger_keydown('down');
156 this.validate_notebook_state('down at end of notebook', 'command', 6);
157 this.trigger_keydown('up');
158 this.validate_notebook_state('up', 'command', 5);
159 this.select_cell(0);
160 this.validate_notebook_state('select 0', 'command', 0);
161 this.trigger_keydown('k');
162 this.validate_notebook_state('k at top of notebook', 'command', 0);
163 this.trigger_keydown('up');
164 this.validate_notebook_state('up at top of notebook', 'command', 0);
165 this.trigger_keydown('down');
166 this.validate_notebook_state('down', 'command', 1);
167
168 // Up and down in edit mode
169 this.click_cell_editor(6);
170 this.validate_notebook_state('click cell 6', 'edit', 6);
171 this.trigger_keydown('down');
172 this.validate_notebook_state('down at end of notebook', 'edit', 6);
173 this.trigger_keydown('up');
174 this.validate_notebook_state('up', 'edit', 5);
175 this.click_cell_editor(0);
176 this.validate_notebook_state('click 0', 'edit', 0);
177 this.trigger_keydown('up');
178 this.validate_notebook_state('up at top of notebook', 'edit', 0);
179 this.trigger_keydown('down');
180 this.validate_notebook_state('down', 'edit', 1);
181
182 // Markdown rendering / unredering
183 this.select_cell(6);
184 this.validate_notebook_state('select 6', 'command', 6);
185 this.trigger_keydown('m');
186 this.test.assertEquals(this.get_cell(6).cell_type, 'markdown', 'm; cell is markdown');
187 this.test.assertEquals(this.get_cell(6).rendered, false, 'm; cell is rendered');
188 this.trigger_keydown('enter');
189 this.test.assertEquals(this.get_cell(6).rendered, false, 'enter; cell is unrendered');
190 this.validate_notebook_state('enter', 'edit', 6);
191 this.trigger_keydown('ctrl+enter');
192 this.test.assertEquals(this.get_cell(6).rendered, true, 'ctrl+enter; cell is rendered');
193 this.validate_notebook_state('enter', 'command', 6);
194 this.trigger_keydown('enter');
195 this.test.assertEquals(this.get_cell(6).rendered, false, 'enter; cell is unrendered');
196 this.select_cell(5);
197 this.test.assertEquals(this.get_cell(6).rendered, false, 'select 5; cell 6 is still unrendered');
198 this.validate_notebook_state('select 5', 'command', 5);
199 this.select_cell(6);
200 this.validate_notebook_state('select 6', 'command', 6);
201 this.trigger_keydown('ctrl+enter');
202 this.test.assertEquals(this.get_cell(6).rendered, true, 'ctrl+enter; cell is rendered');
203 this.select_cell(5);
204 this.validate_notebook_state('select 5', 'command', 5);
205 this.trigger_keydown('shift+enter');
206 this.validate_notebook_state('shift+enter', 'command', 6);
207 this.test.assertEquals(this.get_cell(6).rendered, true, 'shift+enter; cell is rendered');
208 this.trigger_keydown('shift+enter'); // Creates one cell
209 this.validate_notebook_state('shift+enter', 'edit', 7);
210 this.test.assertEquals(this.get_cell(6).rendered, true, 'shift+enter; cell is rendered');
211
212 // Cell movement ( ctrl+(k or j) )
213 this.select_cell(2);
214 this.test.assertEquals(this.get_cell_text(2), b, 'select 2; Cell 2 text is correct');
215 this.trigger_keydown('ctrl+k'); // Move cell 2 up one
216 this.test.assertEquals(this.get_cell_text(1), b, 'ctrl+k; Cell 1 text is correct');
217 this.test.assertEquals(this.get_cell_text(2), a, 'ctrl+k; Cell 2 text is correct');
218 this.validate_notebook_state('ctrl+k', 'command', 1);
219 this.trigger_keydown('ctrl+j'); // Move cell 1 down one
220 this.test.assertEquals(this.get_cell_text(1), a, 'ctrl+j; Cell 1 text is correct');
221 this.test.assertEquals(this.get_cell_text(2), b, 'ctrl+j; Cell 2 text is correct');
222 this.validate_notebook_state('ctrl+j', 'command', 2);
223
224 // Cell insertion
225 this.trigger_keydown('a'); // Creates one cell
226 this.test.assertEquals(this.get_cell_text(2), '', 'a; New cell 2 text is empty');
227 this.validate_notebook_state('a', 'command', 2);
228 this.trigger_keydown('b'); // Creates one cell
229 this.test.assertEquals(this.get_cell_text(2), '', 'b; Cell 2 text is still empty');
230 this.test.assertEquals(this.get_cell_text(3), '', 'b; New cell 3 text is empty');
231 this.validate_notebook_state('b', 'command', 3);
232
233 // Copy/paste/cut
234 var num_cells = this.get_cells_length();
235 this.test.assertEquals(this.get_cell_text(1), a, 'Verify that cell 1 is a');
236 this.select_cell(1);
237 this.trigger_keydown('x'); // Cut
238 this.validate_notebook_state('x', 'command', 1);
239 this.test.assertEquals(this.get_cells_length(), num_cells-1, 'Verify that a cell was removed.');
240 this.test.assertEquals(this.get_cell_text(1), '', 'Verify that cell 2 is now where cell 1 was.');
241 this.select_cell(2);
242 this.trigger_keydown('v'); // Paste
243 this.validate_notebook_state('v', 'command', 3); // Selection should move to pasted cell, below current cell.
244 this.test.assertEquals(this.get_cell_text(3), a, 'Verify that cell 3 has the cut contents.');
245 this.test.assertEquals(this.get_cells_length(), num_cells, 'Verify a the cell was added.');
246 this.trigger_keydown('v'); // Paste
247 this.validate_notebook_state('v', 'command', 4); // Selection should move to pasted cell, below current cell.
248 this.test.assertEquals(this.get_cell_text(4), a, 'Verify that cell 4 has the cut contents.');
249 this.test.assertEquals(this.get_cells_length(), num_cells+1, 'Verify a the cell was added.');
250 this.select_cell(5);
251 this.trigger_keydown('c'); // Copy
252 this.validate_notebook_state('c', 'command', 5);
253 this.test.assertEquals(this.get_cell_text(5), b, 'Verify that cell 5 is b');
254 this.select_cell(6);
255 this.trigger_keydown('c'); // Copy
256 this.validate_notebook_state('c', 'command', 6);
257 this.test.assertEquals(this.get_cell_text(6), c, 'Verify that cell 6 is c');
258 this.trigger_keydown('v'); // Paste
259 this.validate_notebook_state('v', 'command', 7);
260 this.test.assertEquals(this.get_cell_text(6), c, 'Verify that cell 6 still has the copied contents.');
261 this.test.assertEquals(this.get_cell_text(7), c, 'Verify that cell 7 has the copied contents.');
262 this.test.assertEquals(this.get_cells_length(), num_cells+2, 'Verify a the cell was added.');
263 this.select_cell(0);
264 this.trigger_keydown('shift+v'); // Paste
265 this.validate_notebook_state('shift+v', 'command', 0);
266 this.test.assertEquals(this.get_cell_text(0), c, 'Verify that cell 0 has the copied contents.');
267 this.test.assertEquals(this.get_cells_length(), num_cells+3, 'Verify a the cell was added.');
268
269 // Split and merge cells
270 this.select_cell(0);
271 this.trigger_keydown('a', 'enter'); // Create cell above and enter edit mode.
272 this.validate_notebook_state('a, enter', 'edit', 0);
273 this.set_cell_text(0, 'abcd');
274 this.set_cell_editor_cursor(0, 0, 2);
275 this.test.assertEquals(this.get_cell_text(0), 'abcd', 'Verify that cell 0 has the new contents.');
276 this.trigger_keydown('alt+-'); // Split
277 this.test.assertEquals(this.get_cell_text(0), 'ab', 'split; Verify that cell 0 has the first half.');
278 this.test.assertEquals(this.get_cell_text(1), 'cd', 'split; Verify that cell 1 has the second half.');
279 this.validate_notebook_state('split', 'edit', 1);
280 this.select_cell(0); // Move up to cell 0
281 this.trigger_keydown('shift+m'); // Merge
282 this.validate_notebook_state('merge', 'command', 0);
283 this.test.assertEquals(this.get_cell_text(0), 'ab\ncd', 'merge; Verify that cell 0 has the merged contents.');
284 });
77 });
285 });
78 });
1 NO CONTENT: file renamed from IPython/html/tests/notebook/merge_cells.js to IPython/html/tests/notebook/merge_cells_api.js
NO CONTENT: file renamed from IPython/html/tests/notebook/merge_cells.js to IPython/html/tests/notebook/merge_cells_api.js
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now