Show More
@@ -1,78 +1,78 | |||
|
1 | 1 | // |
|
2 | 2 | // Test code cell execution. |
|
3 | 3 | // |
|
4 | 4 | casper.notebook_test(function () { |
|
5 | 5 | this.evaluate(function () { |
|
6 | 6 | var cell = IPython.notebook.get_cell(0); |
|
7 | 7 | cell.set_text('a=10; print(a)'); |
|
8 | 8 | cell.execute(); |
|
9 | 9 | }); |
|
10 | 10 | |
|
11 | 11 | this.wait_for_output(0); |
|
12 | 12 | |
|
13 | 13 | // refactor this into just a get_output(0) |
|
14 | 14 | this.then(function () { |
|
15 | 15 | var result = this.get_output_cell(0); |
|
16 | 16 | this.test.assertEquals(result.text, '10\n', 'cell execute (using js)'); |
|
17 | 17 | }); |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | // do it again with the keyboard shortcut |
|
21 | 21 | this.thenEvaluate(function () { |
|
22 | 22 | var cell = IPython.notebook.get_cell(0); |
|
23 | 23 | cell.set_text('a=11; print(a)'); |
|
24 | 24 | cell.clear_output(); |
|
25 | 25 | }); |
|
26 | 26 | |
|
27 | 27 | this.then(function(){ |
|
28 | 28 | |
|
29 | 29 | this.trigger_keydown('shift-enter'); |
|
30 | 30 | }); |
|
31 | 31 | |
|
32 | 32 | this.wait_for_output(0); |
|
33 | 33 | |
|
34 | 34 | this.then(function () { |
|
35 | 35 | var result = this.get_output_cell(0); |
|
36 | 36 | var num_cells = this.get_cells_length(); |
|
37 | 37 | this.test.assertEquals(result.text, '11\n', 'cell execute (using ctrl-enter)'); |
|
38 | 38 | this.test.assertEquals(num_cells, 2, 'shift-enter adds a new cell at the bottom') |
|
39 | 39 | }); |
|
40 | 40 | |
|
41 | 41 | // do it again with the keyboard shortcut |
|
42 | 42 | this.thenEvaluate(function () { |
|
43 | 43 | IPython.notebook.select(1); |
|
44 | 44 | IPython.notebook.delete_cell(); |
|
45 | 45 | var cell = IPython.notebook.get_cell(0); |
|
46 | 46 | cell.set_text('a=12; print(a)'); |
|
47 | 47 | cell.clear_output(); |
|
48 | 48 | }); |
|
49 | 49 | |
|
50 | 50 | this.then(function(){ |
|
51 | 51 | this.trigger_keydown('ctrl-enter'); |
|
52 | 52 | }); |
|
53 | 53 | |
|
54 | 54 | this.wait_for_output(0); |
|
55 | 55 | |
|
56 | 56 | this.then(function () { |
|
57 | 57 | var result = this.get_output_cell(0); |
|
58 | 58 | var num_cells = this.get_cells_length(); |
|
59 | 59 | this.test.assertEquals(result.text, '12\n', 'cell execute (using shift-enter)'); |
|
60 | 60 | this.test.assertEquals(num_cells, 1, 'ctrl-enter adds no new cell at the bottom') |
|
61 | 61 | }); |
|
62 | 62 | |
|
63 | 63 | // press the "play" triangle button in the toolbar |
|
64 | 64 | this.thenEvaluate(function () { |
|
65 | 65 | var cell = IPython.notebook.get_cell(0); |
|
66 | 66 | IPython.notebook.select(0); |
|
67 | 67 | cell.clear_output(); |
|
68 | 68 | cell.set_text('a=13; print(a)'); |
|
69 |
$("button[data-jupyter-action='ipython. |
|
|
69 | $("button[data-jupyter-action='ipython.run-select-next']")[0].click() | |
|
70 | 70 | }); |
|
71 | 71 | |
|
72 | 72 | this.wait_for_output(0); |
|
73 | 73 | |
|
74 | 74 | this.then(function () { |
|
75 | 75 | var result = this.get_output_cell(0); |
|
76 | 76 | this.test.assertEquals(result.text, '13\n', 'cell execute (using "play" toolbar button)') |
|
77 | 77 | }); |
|
78 | 78 | }); |
@@ -1,62 +1,62 | |||
|
1 | 1 | // |
|
2 | 2 | // Test that a Markdown cell is rendered to HTML. |
|
3 | 3 | // |
|
4 | 4 | casper.notebook_test(function () { |
|
5 | 5 | // Test JavaScript models. |
|
6 | 6 | var output = this.evaluate(function () { |
|
7 | 7 | IPython.notebook.to_markdown(); |
|
8 | 8 | var cell = IPython.notebook.get_selected_cell(); |
|
9 | 9 | cell.set_text('# Foo'); |
|
10 | 10 | cell.render(); |
|
11 | 11 | return cell.get_rendered(); |
|
12 | 12 | }); |
|
13 | 13 | this.test.assertEquals(output.trim(), '<h1 id=\"Foo\">Foo<a class=\"anchor-link\" href=\"#Foo\">ΒΆ</a></h1>', 'Markdown JS API works.'); |
|
14 | 14 | |
|
15 | 15 | // Test menubar entries. |
|
16 | 16 | output = this.evaluate(function () { |
|
17 | 17 | $('#to_code').mouseenter().click(); |
|
18 | 18 | $('#to_markdown').mouseenter().click(); |
|
19 | 19 | var cell = IPython.notebook.get_selected_cell(); |
|
20 | 20 | cell.set_text('**Bar**'); |
|
21 | 21 | $('#run_cell').mouseenter().click(); |
|
22 | 22 | return cell.get_rendered(); |
|
23 | 23 | }); |
|
24 | 24 | this.test.assertEquals(output.trim(), '<p><strong>Bar</strong></p>', 'Markdown menubar items work.'); |
|
25 | 25 | |
|
26 | 26 | // Test toolbar buttons. |
|
27 | 27 | output = this.evaluate(function () { |
|
28 | 28 | $('#cell_type').val('code').change(); |
|
29 | 29 | $('#cell_type').val('markdown').change(); |
|
30 | 30 | var cell = IPython.notebook.get_selected_cell(); |
|
31 | 31 | cell.set_text('*Baz*'); |
|
32 |
$("button[data-jupyter-action='ipython. |
|
|
32 | $("button[data-jupyter-action='ipython.run-select-next']")[0].click(); | |
|
33 | 33 | return cell.get_rendered(); |
|
34 | 34 | }); |
|
35 | 35 | this.test.assertEquals(output.trim(), '<p><em>Baz</em></p>', 'Markdown toolbar items work.'); |
|
36 | 36 | |
|
37 | 37 | // Test markdown headings |
|
38 | 38 | |
|
39 | 39 | var text = 'multi\nline'; |
|
40 | 40 | |
|
41 | 41 | this.evaluate(function (text) { |
|
42 | 42 | var cell = IPython.notebook.insert_cell_at_index('markdown', 0); |
|
43 | 43 | cell.set_text(text); |
|
44 | 44 | }, {text: text}); |
|
45 | 45 | |
|
46 | 46 | var set_level = function (level) { |
|
47 | 47 | return casper.evaluate(function (level) { |
|
48 | 48 | var cell = IPython.notebook.get_cell(0); |
|
49 | 49 | cell.set_heading_level(level); |
|
50 | 50 | return cell.get_text(); |
|
51 | 51 | }, {level: level}); |
|
52 | 52 | }; |
|
53 | 53 | |
|
54 | 54 | var level_text; |
|
55 | 55 | var levels = [ 1, 2, 3, 4, 5, 6, 2, 1 ]; |
|
56 | 56 | for (var idx=0; idx < levels.length; idx++) { |
|
57 | 57 | var level = levels[idx]; |
|
58 | 58 | level_text = set_level(level); |
|
59 | 59 | hashes = new Array(level + 1).join('#'); |
|
60 | 60 | this.test.assertEquals(level_text, hashes + ' ' + text, 'markdown set_heading_level ' + level); |
|
61 | 61 | } |
|
62 | 62 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now