mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-09 03:50:45 +08:00
Add test for attachments garbage collection
This commit is contained in:
parent
51cab51f1c
commit
f50474d60d
@ -3,7 +3,7 @@
|
||||
//
|
||||
var fs = require('fs');
|
||||
casper.notebook_test(function () {
|
||||
// Test the Edit->Insert Image menu to insert new attachments
|
||||
// -- Test the Edit->Insert Image menu to insert new attachments
|
||||
"use strict";
|
||||
casper.test.info("Testing attachments insertion through the menuitem");
|
||||
|
||||
@ -70,7 +70,7 @@ casper.notebook_test(function () {
|
||||
//this.capture('test.png');
|
||||
//});
|
||||
|
||||
// Use the Edit->Copy/Paste Cell Attachments menu items
|
||||
// -- Use the Edit->Copy/Paste Cell Attachments menu items
|
||||
selector = '#copy_cell_attachments > a';
|
||||
this.waitForSelector(selector);
|
||||
this.thenClick(selector);
|
||||
@ -85,8 +85,6 @@ casper.notebook_test(function () {
|
||||
selector = '#paste_cell_attachments > a';
|
||||
this.waitForSelector(selector);
|
||||
this.thenClick(selector);
|
||||
// Small delay so the paste has the time to complete
|
||||
this.wait(500);
|
||||
|
||||
// check that the new cell has attachments
|
||||
this.then(function() {
|
||||
@ -101,5 +99,25 @@ casper.notebook_test(function () {
|
||||
this.test.assertEquals(cell.attachments, orig_cell.attachments,
|
||||
"both cells have the attachments");
|
||||
});
|
||||
|
||||
// -- Save the notebook. This should cause garbage collection for the
|
||||
// second cell (since we just pasted the attachments but there is no
|
||||
// markdown referencing them)
|
||||
this.thenEvaluate(function() {
|
||||
IPython.notebook.save_checkpoint();
|
||||
});
|
||||
|
||||
this.then(function() {
|
||||
var cell0 = this.evaluate(function() {
|
||||
return IPython.notebook.get_cell(0);
|
||||
});
|
||||
var cell1 = this.evaluate(function() {
|
||||
return IPython.notebook.get_cell(1);
|
||||
});
|
||||
this.test.assert('black_square_22.png' in cell0.attachments,
|
||||
'cell0 has kept its attachments');
|
||||
this.test.assertEquals(Object.keys(cell1.attachments).length, 0,
|
||||
'cell1 attachments have been garbage collected');
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user