Show More
@@ -0,0 +1,80 b'' | |||||
|
1 | // Test container class | |||
|
2 | casper.notebook_test(function () { | |||
|
3 | index = this.append_cell( | |||
|
4 | 'from IPython.html import widgets\n' + | |||
|
5 | 'from IPython.display import display, clear_output\n' + | |||
|
6 | 'print("Success")'); | |||
|
7 | this.execute_cell_then(index); | |||
|
8 | ||||
|
9 | var container_index = this.append_cell( | |||
|
10 | 'container = widgets.ContainerWidget()\n' + | |||
|
11 | 'button = widgets.ButtonWidget()\n'+ | |||
|
12 | 'container.children = [button]\n'+ | |||
|
13 | 'display(container)\n'+ | |||
|
14 | 'container.add_class("my-test-class")\n'+ | |||
|
15 | 'print("Success")\n'); | |||
|
16 | this.execute_cell_then(container_index, function(index){ | |||
|
17 | ||||
|
18 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
19 | 'Create container cell executed with correct output.'); | |||
|
20 | ||||
|
21 | this.test.assert(this.cell_element_exists(index, | |||
|
22 | '.widget-area .widget-subarea'), | |||
|
23 | 'Widget subarea exists.'); | |||
|
24 | ||||
|
25 | this.test.assert(this.cell_element_exists(index, | |||
|
26 | '.widget-area .widget-subarea .widget-container'), | |||
|
27 | 'Widget container exists.'); | |||
|
28 | ||||
|
29 | this.test.assert(this.cell_element_exists(index, | |||
|
30 | '.widget-area .widget-subarea .my-test-class'), | |||
|
31 | 'add_class works.'); | |||
|
32 | ||||
|
33 | this.test.assert(this.cell_element_exists(index, | |||
|
34 | '.widget-area .widget-subarea .my-test-class button'), | |||
|
35 | 'Container parent/child relationship works.'); | |||
|
36 | }); | |||
|
37 | ||||
|
38 | index = this.append_cell( | |||
|
39 | 'container.set_css("float", "right")\n'+ | |||
|
40 | 'print("Success")\n'); | |||
|
41 | this.execute_cell_then(index, function(index){ | |||
|
42 | ||||
|
43 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
44 | 'Set container class CSS cell executed with correct output.'); | |||
|
45 | ||||
|
46 | this.test.assert(this.cell_element_function(container_index, | |||
|
47 | '.widget-area .widget-subarea .my-test-class', 'css', ['float'])=='right', | |||
|
48 | 'set_css works.'); | |||
|
49 | }); | |||
|
50 | ||||
|
51 | index = this.append_cell( | |||
|
52 | 'container.remove_class("my-test-class")\n'+ | |||
|
53 | 'print("Success")\n'); | |||
|
54 | this.execute_cell_then(index, function(index){ | |||
|
55 | ||||
|
56 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
57 | 'Remove container class cell executed with correct output.'); | |||
|
58 | ||||
|
59 | this.test.assert(! this.cell_element_exists(container_index, | |||
|
60 | '.widget-area .widget-subarea .my-test-class'), | |||
|
61 | 'remove_class works.'); | |||
|
62 | }); | |||
|
63 | ||||
|
64 | index = this.append_cell( | |||
|
65 | 'display(button)\n'+ | |||
|
66 | 'print("Success")\n'); | |||
|
67 | this.execute_cell_then(index, function(index){ | |||
|
68 | ||||
|
69 | this.test.assert(this.get_output_cell(index).text == 'Success\n', | |||
|
70 | 'Display container child executed with correct output.'); | |||
|
71 | ||||
|
72 | this.test.assert(! this.cell_element_exists(index, | |||
|
73 | '.widget-area .widget-subarea .widget-container'), | |||
|
74 | 'Parent container not displayed.'); | |||
|
75 | ||||
|
76 | this.test.assert(this.cell_element_exists(index, | |||
|
77 | '.widget-area .widget-subarea button'), | |||
|
78 | 'Child displayed.'); | |||
|
79 | }); | |||
|
80 | }); No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now