##// END OF EJS Templates
use global events in js tests
MinRK -
Show More
@@ -9,16 +9,18 casper.notebook_test(function () {
9 var nbname = "has#hash and space and unicø∂e.ipynb";
9 var nbname = "has#hash and space and unicø∂e.ipynb";
10
10
11 this.evaluate(function (nbname) {
11 this.evaluate(function (nbname) {
12 IPython.notebook.notebook_name = nbname;
12 require(['base/js/events'], function (events) {
13 IPython._save_success = IPython._save_failed = false;
13 IPython.notebook.notebook_name = nbname;
14 IPython.events.on('notebook_saved.Notebook', function () {
14 IPython._save_success = IPython._save_failed = false;
15 IPython._save_success = true;
15 events.on('notebook_saved.Notebook', function () {
16 });
16 IPython._save_success = true;
17 IPython.events.on('notebook_save_failed.Notebook',
17 });
18 function (event, xhr, status, error) {
18 events.on('notebook_save_failed.Notebook',
19 IPython._save_failed = "save failed with " + xhr.status + xhr.responseText;
19 function (event, xhr, status, error) {
20 IPython._save_failed = "save failed with " + xhr.status + xhr.responseText;
21 });
22 IPython.notebook.save_notebook();
20 });
23 });
21 IPython.notebook.save_notebook();
22 }, {nbname:nbname});
24 }, {nbname:nbname});
23
25
24 this.waitFor(function () {
26 this.waitFor(function () {
@@ -41,10 +43,12 casper.notebook_test(function () {
41 });
43 });
42
44
43 this.thenEvaluate(function(){
45 this.thenEvaluate(function(){
44 IPython.events.on('checkpoint_created.Notebook', function (evt, data) {
45 IPython._checkpoint_created = true;
46 });
47 IPython._checkpoint_created = false;
46 IPython._checkpoint_created = false;
47 require(['base/js/events'], function (events) {
48 events.on('checkpoint_created.Notebook', function (evt, data) {
49 IPython._checkpoint_created = true;
50 });
51 });
48 IPython.notebook.save_checkpoint();
52 IPython.notebook.save_checkpoint();
49 });
53 });
50
54
@@ -71,7 +75,7 casper.notebook_test(function () {
71 this.then(function(){
75 this.then(function(){
72 var notebook_url = this.evaluate(function(nbname){
76 var notebook_url = this.evaluate(function(nbname){
73 var escaped_name = encodeURIComponent(nbname);
77 var escaped_name = encodeURIComponent(nbname);
74 var return_this_thing;
78 var return_this_thing = null;
75 $("a.item_link").map(function (i,a) {
79 $("a.item_link").map(function (i,a) {
76 if (a.href.indexOf(escaped_name) >= 0) {
80 if (a.href.indexOf(escaped_name) >= 0) {
77 return_this_thing = a.href;
81 return_this_thing = a.href;
@@ -26,11 +26,14 casper.open_new_notebook = function () {
26 this.waitFor(this.kernel_running);
26 this.waitFor(this.kernel_running);
27 // track the IPython busy/idle state
27 // track the IPython busy/idle state
28 this.thenEvaluate(function () {
28 this.thenEvaluate(function () {
29 IPython.events.on('status_idle.Kernel',function () {
29 require(['base/js/namespace', 'base/js/events'], function (IPython, events) {
30 IPython._status = 'idle';
30
31 });
31 events.on('status_idle.Kernel',function () {
32 IPython.events.on('status_busy.Kernel',function () {
32 IPython._status = 'idle';
33 IPython._status = 'busy';
33 });
34 events.on('status_busy.Kernel',function () {
35 IPython._status = 'busy';
36 });
34 });
37 });
35 });
38 });
36
39
General Comments 0
You need to be logged in to leave comments. Login now