Browse Source

Add test for code cell as the last selected cell

Jeremy Tuloup 5 years ago
parent
commit
2f87d76ddc
1 changed files with 19 additions and 2 deletions
  1. 19 2
      packages/notebook/test/actions.spec.ts

+ 19 - 2
packages/notebook/test/actions.spec.ts

@@ -273,7 +273,7 @@ describe('@jupyterlab/notebook', () => {
       it('should merge attachments if the last selected cell is a markdown cell', () => {
         for (let i = 0; i < 2; i++) {
           NotebookActions.changeCellType(widget, 'markdown');
-          const markdownCell = widget.activeCell as MarkdownCell;
+          const markdownCell = widget.widgets[i] as MarkdownCell;
           const attachment: IMimeBundle = { 'text/plain': 'test' };
           markdownCell.model.attachments.set(UUID.uuid4(), attachment);
           widget.select(markdownCell);
@@ -284,7 +284,24 @@ describe('@jupyterlab/notebook', () => {
       });
 
       it('should drop attachments if the last selected cell is a code cell', () => {
-        // TODO
+        NotebookActions.changeCellType(widget, 'markdown');
+        const markdownCell = widget.activeCell as MarkdownCell;
+        const attachment: IMimeBundle = { 'text/plain': 'test' };
+        markdownCell.model.attachments.set(UUID.uuid4(), attachment);
+
+        const codeCell = widget.widgets[1];
+        widget.select(codeCell);
+        NotebookActions.changeCellType(widget, 'code');
+        NotebookActions.deselectAll(widget);
+
+        widget.select(markdownCell);
+        widget.select(codeCell);
+
+        NotebookActions.mergeCells(widget);
+
+        const model = widget.activeCell!.model.toJSON();
+        expect(model.cell_type).toEqual('code');
+        expect(model.attachments).toBeUndefined();
       });
     });