Steven Silvester 8 éve
szülő
commit
8e47091c37

+ 18 - 18
test/src/notebook/actions.spec.ts

@@ -28,7 +28,7 @@ import {
 } from '../../../lib/notebook/widget';
 
 import {
-  DEFAULT_CONTENT, createNotebookFactory, clipboard, rendermime,
+  DEFAULT_CONTENT, createNotebookFactory, rendermime, clipboard,
   mimeTypeService
 } from './utils';
 
@@ -1020,7 +1020,7 @@ describe('notebook/notebook/actions', () => {
       it('should copy the selected cells to a clipboard', () => {
         let next = widget.widgets[1];
         widget.select(next);
-        NotebookActions.copy(widget, clipboard);
+        NotebookActions.copy(widget);
         expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(true);
         let data = clipboard.getData(JUPYTER_CELL_MIME);
         expect(data.length).to.be(2);
@@ -1028,13 +1028,13 @@ describe('notebook/notebook/actions', () => {
 
       it('should be a no-op if there is no model', () => {
         widget.model = null;
-        NotebookActions.copy(widget, clipboard);
+        NotebookActions.copy(widget);
         expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(false);
       });
 
       it('should change to command mode', () => {
         widget.mode = 'edit';
-        NotebookActions.copy(widget, clipboard);
+        NotebookActions.copy(widget);
         expect(widget.mode).to.be('command');
       });
 
@@ -1046,25 +1046,25 @@ describe('notebook/notebook/actions', () => {
         let next = widget.widgets[1];
         widget.select(next);
         let count = widget.widgets.length;
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         expect(widget.widgets.length).to.be(count - 2);
       });
 
       it('should be a no-op if there is no model', () => {
         widget.model = null;
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         expect(clipboard.hasData(JUPYTER_CELL_MIME)).to.be(false);
       });
 
       it('should change to command mode', () => {
         widget.mode = 'edit';
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         expect(widget.mode).to.be('command');
       });
 
       it('should be undo-able', () => {
         let source = widget.activeCell.model.value.text;
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         NotebookActions.undo(widget);
         expect(widget.widgets[0].model.value.text).to.be(source);
       });
@@ -1073,7 +1073,7 @@ describe('notebook/notebook/actions', () => {
         for (let i = 0; i < widget.widgets.length; i++) {
           widget.select(widget.widgets[i]);
         }
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         requestAnimationFrame(() => {
           expect(widget.widgets.length).to.be(1);
           expect(widget.activeCell).to.be.a(CodeCellWidget);
@@ -1090,31 +1090,31 @@ describe('notebook/notebook/actions', () => {
         let next = widget.widgets[1];
         widget.select(next);
         let count = widget.widgets.length;
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         widget.activeCellIndex = 1;
-        NotebookActions.paste(widget, clipboard);
+        NotebookActions.paste(widget);
         expect(widget.widgets.length).to.be(count);
         expect(widget.widgets[2].model.value.text).to.be(source);
         expect(widget.activeCellIndex).to.be(3);
       });
 
       it('should be a no-op if there is no model', () => {
-        NotebookActions.copy(widget, clipboard);
+        NotebookActions.copy(widget);
         widget.model = null;
-        NotebookActions.paste(widget, clipboard);
+        NotebookActions.paste(widget);
         expect(widget.activeCellIndex).to.be(-1);
       });
 
       it('should be a no-op if there is no cell data on the clipboard', () => {
         let count = widget.widgets.length;
-        NotebookActions.paste(widget, clipboard);
+        NotebookActions.paste(widget);
         expect(widget.widgets.length).to.be(count);
       });
 
       it('should change to command mode', () => {
         widget.mode = 'edit';
-        NotebookActions.cut(widget, clipboard);
-        NotebookActions.paste(widget, clipboard);
+        NotebookActions.cut(widget);
+        NotebookActions.paste(widget);
         expect(widget.mode).to.be('command');
       });
 
@@ -1122,9 +1122,9 @@ describe('notebook/notebook/actions', () => {
         let next = widget.widgets[1];
         widget.select(next);
         let count = widget.widgets.length;
-        NotebookActions.cut(widget, clipboard);
+        NotebookActions.cut(widget);
         widget.activeCellIndex = 1;
-        NotebookActions.paste(widget, clipboard);
+        NotebookActions.paste(widget);
         NotebookActions.undo(widget);
         expect(widget.widgets.length).to.be(count - 2);
       });

+ 2 - 2
test/src/notebook/default-toolbar.spec.ts

@@ -91,7 +91,7 @@ describe('notebook/notebook/default-toolbar', () => {
     const contentFactory = createNotebookPanelFactory();
 
     beforeEach(() => {
-      panel = new NotebookPanel({ rendermime, clipboard, contentFactory,
+      panel = new NotebookPanel({ rendermime, contentFactory,
                                   mimeTypeService });
       context.model.fromJSON(DEFAULT_CONTENT);
       panel.context = context;
@@ -182,7 +182,7 @@ describe('notebook/notebook/default-toolbar', () => {
         let button = ToolbarItems.createPasteButton(panel);
         let count = panel.notebook.widgets.length;
         Widget.attach(button, document.body);
-        NotebookActions.copy(panel.notebook, clipboard);
+        NotebookActions.copy(panel.notebook);
         button.node.click();
         requestAnimationFrame(() => {
           expect(panel.notebook.widgets.length).to.be(count + 1);

+ 4 - 13
test/src/notebook/panel.spec.ts

@@ -36,7 +36,7 @@ import {
 } from '../utils';
 
 import {
-  DEFAULT_CONTENT, createNotebookPanelFactory, rendermime, clipboard,
+  DEFAULT_CONTENT, createNotebookPanelFactory, rendermime,
   mimeTypeService, editorFactory
 } from './utils';
 
@@ -45,7 +45,7 @@ import {
  * Default data.
  */
 const contentFactory = createNotebookPanelFactory();
-const options = { rendermime, clipboard, mimeTypeService, contentFactory };
+const options = { rendermime, mimeTypeService, contentFactory };
 
 
 class LogNotebookPanel extends NotebookPanel {
@@ -112,7 +112,7 @@ describe('notebook/notebook/panel', () => {
       it('should accept an optional content factory', () => {
         let newFactory = createNotebookPanelFactory();
         let panel = new NotebookPanel({
-          mimeTypeService, rendermime, clipboard, contentFactory: newFactory
+          mimeTypeService, rendermime, contentFactory: newFactory
         });
         expect(panel.contentFactory).to.be(newFactory);
       });
@@ -207,21 +207,12 @@ describe('notebook/notebook/panel', () => {
       it('should be the contentFactory used by the widget', () => {
         let r = createNotebookPanelFactory();
         let panel = new NotebookPanel({
-          mimeTypeService, rendermime, clipboard, contentFactory: r });
+          mimeTypeService, rendermime, contentFactory: r });
         expect(panel.contentFactory).to.be(r);
       });
 
     });
 
-    describe('#clipboard', () => {
-
-      it('should be the clipboard instance used by the widget', () => {
-        let panel = new NotebookPanel(options);
-        expect(panel.clipboard).to.be(clipboard);
-      });
-
-    });
-
     describe('#model', () => {
 
       it('should be the model for the widget', () => {

+ 6 - 7
test/src/notebook/utils.ts

@@ -5,10 +5,6 @@ import {
   nbformat
 } from '@jupyterlab/services';
 
-import {
-  MimeData
-} from '@phosphor/coreutils';
-
 import {
   editorServices
 } from '../../../lib/codemirror';
@@ -17,6 +13,10 @@ import {
   CodeEditorWidget
 } from '../../../lib/codeeditor';
 
+import {
+  Clipboard
+} from '../../../lib/common/clipboard';
+
 import {
   NotebookPanel, Notebook, NotebookModel
 } from '../../../lib/notebook';
@@ -46,7 +46,7 @@ export
 const rendermime = defaultRenderMime();
 
 export
-const clipboard = new MimeData();
+const clipboard = Clipboard.getInstance();
 
 
 /**
@@ -118,8 +118,7 @@ function createNotebookPanel(): NotebookPanel {
   return new NotebookPanel({
     rendermime,
     contentFactory: createNotebookPanelFactory(),
-    mimeTypeService,
-    clipboard
+    mimeTypeService
   });
 }
 

+ 1 - 2
test/src/notebook/widgetfactory.spec.ts

@@ -28,7 +28,7 @@ import {
 } from '../utils';
 
 import {
-  createNotebookPanelFactory, clipboard, rendermime, mimeTypeService
+  createNotebookPanelFactory, rendermime, mimeTypeService
 } from './utils';
 
 
@@ -40,7 +40,6 @@ function createFactory(): NotebookWidgetFactory {
     name: 'notebook',
     fileExtensions: ['.ipynb'],
     rendermime,
-    clipboard,
     contentFactory,
     mimeTypeService
   });