misc.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Miscellaneous javascript tests
  3. //
  4. casper.notebook_test(function () {
  5. var jsver = this.evaluate(function () {
  6. var cell = IPython.notebook.get_cell(0);
  7. cell.set_text('import notebook; print(notebook.__version__)');
  8. cell.execute();
  9. return IPython.version;
  10. });
  11. this.wait_for_output(0);
  12. // refactor this into just a get_output(0)
  13. this.then(function () {
  14. var result = this.get_output_cell(0);
  15. this.test.assertEquals(result.text.trim(), jsver, 'IPython.version in JS matches server-side.');
  16. });
  17. // verify that requirejs loads the same CodeCell prototype at runtime as build time
  18. this.thenEvaluate(function () {
  19. require(['notebook/js/codecell'], function (codecell) {
  20. codecell.CodeCell.prototype.test = function () {
  21. return 'ok';
  22. }
  23. window._waitForMe = true;
  24. })
  25. })
  26. this.waitFor(function () {
  27. return this.evaluate(function () {
  28. return window._waitForMe;
  29. });
  30. })
  31. this.then(function () {
  32. var result = this.evaluate(function () {
  33. var cell = Jupyter.notebook.get_cell(0);
  34. return cell.test();
  35. });
  36. this.test.assertEquals(result, 'ok', "runtime-requirejs loads the same modules")
  37. })
  38. });