소스 검색

wip notebook tests

Steven Silvester 9 년 전
부모
커밋
408b0d38ed
2개의 변경된 파일17개의 추가작업 그리고 10개의 파일을 삭제
  1. 16 10
      src/notebook/notebook/model.ts
  2. 1 0
      test/src/notebook/typings.d.ts

+ 16 - 10
src/notebook/notebook/model.ts

@@ -2,9 +2,6 @@
 // Distributed under the terms of the Modified BSD License.
 'use strict';
 
-import * as CodeMirror
-  from 'codemirror';
-
 import {
   INotebookSession, IExecuteReply
 } from 'jupyter-js-services';
@@ -31,15 +28,15 @@ import {
 
 import {
   EditorModel, IEditorModel, IEditorOptions
-} from '../editor';
+} from '../editor/model';
 
 import {
   InputAreaModel, IInputAreaModel
-} from '../input-area';
+} from '../input-area/model';
 
 import {
   OutputAreaModel, IOutputAreaModel
-} from '../output-area';
+} from '../output-area/model';
 
 import {
   ICellModel,
@@ -47,7 +44,7 @@ import {
   IMarkdownCellModel, MarkdownCellModel,
   IRawCellModel, isCodeCellModel, isMarkdownCellModel,
   RawCellModel, isRawCellModel, MetadataCursor, IMetadataCursor
-} from '../cells';
+} from '../cells/model';
 
 import {
   OutputType, IKernelspecMetadata, ILanguageInfoMetadata
@@ -419,6 +416,10 @@ class NotebookModel implements INotebookModel {
 
   /**
    * The mode of the notebook.
+   *
+   * #### Notes
+   * Selected markdown cells are rendered if mode is set to 'command'
+   * and unrendered if mode is set to 'edit'.
    */
   get mode(): NotebookMode {
     return this._mode;
@@ -595,6 +596,11 @@ class NotebookModel implements INotebookModel {
 
   /**
    * Run the active cell, taking the appropriate action.
+   *
+   * #### Notes
+   * If the notebook is read-only or has no active cell, this is a no-op.
+   * Markdown cells are rendered and code cells are executed.
+   * All cells are marked as trusted.
    */
   runActiveCell(): void {
     if (this.readOnly) {
@@ -604,7 +610,6 @@ class NotebookModel implements INotebookModel {
     if (!cell) {
       return;
     }
-    this.mode = 'command';
     if (isMarkdownCellModel(cell)) {
       cell.rendered = false;
       cell.trusted = true;
@@ -734,7 +739,7 @@ class NotebookModel implements INotebookModel {
   private _kernelspec = JSON.stringify(DEFAULT_KERNELSPEC);
   private _langInfo = JSON.stringify(DEFAULT_LANG_INFO);
   private _origNbformat: number = null;
-  private _activeCellIndex = -1;
+  private _activeCellIndex: number = null;
   private _mode: NotebookMode = 'command';
   private _dirty = false;
 }
@@ -767,7 +772,8 @@ namespace NotebookModelPrivate {
    */
   export
   const selectedProperty = new Property<ICellModel, boolean>({
-    name: 'selected'
+    name: 'selected',
+    value: false
   });
 
   /**

+ 1 - 0
test/src/notebook/typings.d.ts

@@ -1,2 +1,3 @@
 /// <reference path="../../typings/expect.js/expect.js.d.ts"/>
 /// <reference path="../../typings/mocha/mocha.d.ts"/>
+/// <reference path="../../typings/es6-promise/es6-promise.d.ts"/>