##// END OF EJS Templates
Renamed widgets......
Renamed widgets... TextWidget, TextareaWidget, CheckboxWidget, and SelectWidget

File last commit:

r14834:5ed93769
r14834:5ed93769
Show More
widgets.js
69 lines | 2.6 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Add basic widget.js tests
r14309 // Test the widget framework.
casper.notebook_test(function () {
Jonathan Frederic
Cleaned up utilities in widget casper js tests
r14435 var index;
Jonathan Frederic
Make widget tests use new casper util functions
r14436
Jonathan Frederic
Add basic widget.js tests
r14309 this.then(function () {
// Check if the WidgetManager class is defined.
this.test.assert(this.evaluate(function() {
MinRK
first review pass on widget tests
r14797 return IPython.WidgetManager !== undefined;
Jonathan Frederic
Add basic widget.js tests
r14309 }), 'WidgetManager class is defined');
Jonathan Frederic
Fixed casperjs widget tests...
r14350 });
Jonathan Frederic
Make widget tests use new casper util functions
r14436 index = this.append_cell(
Jonathan Frederic
Cleaned up utilities in widget casper js tests
r14435 'from IPython.html import widgets\n' +
'from IPython.display import display, clear_output\n' +
'print("Success")');
Jonathan Frederic
Make widget tests use new casper util functions
r14436 this.execute_cell_then(index);
Jonathan Frederic
Cleaned up utilities in widget casper js tests
r14435
Jonathan Frederic
Fixed casperjs widget tests...
r14350 this.wait(500); // Wait for require.js async callbacks to load dependencies.
this.then(function () {
MinRK
first review pass on widget tests
r14797 // Check if the widget manager has been instantiated.
Jonathan Frederic
Add basic widget.js tests
r14309 this.test.assert(this.evaluate(function() {
MinRK
first review pass on widget tests
r14797 return IPython.notebook.kernel.widget_manager !== undefined;
}), 'Notebook widget manager instantiated');
Jonathan Frederic
Add basic widget.js tests
r14309 });
Jonathan Frederic
Added throttling test
r14463 throttle_index = this.append_cell(
'import time\n' +
Jonathan Frederic
Renamed widgets......
r14834 'textbox = widgets.TextWidget()\n' +
Jonathan Frederic
Added throttling test
r14463 'display(textbox)\n'+
'textbox.add_class("my-throttle-textbox")\n' +
'def handle_change(name, old, new):\n' +
' print(len(new))\n' +
' time.sleep(0.5)\n' +
MinRK
first review pass on widget tests
r14797 'textbox.on_trait_change(handle_change, "value")\n' +
Jonathan Frederic
Added throttling test
r14463 'print("Success")');
this.execute_cell_then(throttle_index, function(index){
MinRK
first review pass on widget tests
r14797 this.test.assertEquals(this.get_output_cell(index).text, 'Success\n',
Jonathan Frederic
Added throttling test
r14463 'Test throttling cell executed with correct output');
this.test.assert(this.cell_element_exists(index,
'.widget-area .widget-subarea'),
'Widget subarea exists.');
this.test.assert(this.cell_element_exists(index,
'.my-throttle-textbox'), 'Textbox exists.');
// Send 20 characters
this.sendKeys('.my-throttle-textbox', '....................');
});
this.wait(2000); // Wait for clicks to execute in kernel
this.then(function(){
MinRK
first review pass on widget tests
r14797 var outputs = this.evaluate(function(i) {
return IPython.notebook.get_cell(i).output_area.outputs;
}, {i : throttle_index});
Jonathan Frederic
Added throttling test
r14463
// Only 4 outputs should have printed, but because of timing, sometimes
// 5 outputs will print. All we need to do is verify num outputs <= 5
// because that is much less than 20.
MinRK
first review pass on widget tests
r14797 this.test.assert(outputs.length <= 5, 'Messages throttled.');
Jonathan Frederic
Added throttling test
r14463
// We also need to verify that the last state sent was correct.
MinRK
first review pass on widget tests
r14797 var last_state = outputs[outputs.length-1].text;
this.test.assertEquals(last_state, "20\n", "Last state sent when throttling.");
Jonathan Frederic
Fixed widget_manager instance test.
r14625 });
Jonathan Frederic
Added int range and int widget tests.
r14454 });