当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fileeditor.FileEditor类代码示例

本文整理汇总了TypeScript中@jupyterlab/fileeditor.FileEditor的典型用法代码示例。如果您正苦于以下问题:TypeScript FileEditor类的具体用法?TypeScript FileEditor怎么用?TypeScript FileEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileEditor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

  describe('FileEditor', () => {

    let widget: FileEditor;

    beforeEach(() => {
      let path = uuid() + '.py';
      context = new Context({ manager, factory: modelFactory, path });
      widget = new FileEditor({
        factory: options => factoryService.newDocumentEditor(options),
        mimeTypeService,
        context
      });
    });

    afterEach(() => {
      widget.dispose();
    });

    describe('#constructor()', () => {

      it('should create an editor widget', () => {
        expect(widget).to.be.an(FileEditor);
      });

      it('should update the editor text when the model changes', (done) => {
        context.save().catch(done);
        context.ready.then(() => {
          widget.context.model.fromString('foo');
          expect(widget.editor.model.value.text).to.be('foo');
        }).then(done, done);
      });

      it('should set the mime type for the path', () => {
        expect(widget.editor.model.mimeType).to.be('text/x-python');
      });

      it('should update the mime type when the path changes', (done) => {
        context.pathChanged.connect((sender, args) => {
          expect(widget.editor.model.mimeType).to.be('text/x-julia');
          done();
        });
        context.save().then(() => {
          return manager.contents.rename(context.path, uuid() + '.jl');
        }).catch(done);
      });

      it('should set the title for the path', () => {
        expect(widget.title.label).to.be(context.path);
      });

      it('should add the dirty class when the model is dirty', (done) => {
        context.save().catch(done);
        context.ready.then(() => {
          context.model.fromString('bar');
          expect(widget.title.className).to.contain('jp-mod-dirty');
        }).then(done, done);
      });

      it('should update the title when the path changes', (done) => {
        let path = uuid() + '.jl';
        context.pathChanged.connect((sender, args) => {
          expect(widget.title.label).to.be(path);
          done();
        });
        context.save().then(() => {
          return manager.contents.rename(context.path, path);
        }).catch(done);
      });

    });

    describe('#context', () => {

      it('should be the context used by the widget', () => {
        expect(widget.context).to.be(context);
      });

    });

  });
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:80,代码来源:widget.spec.ts

示例2: afterEach

 afterEach(() => {
   widget.dispose();
 });
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:3,代码来源:widget.spec.ts


注:本文中的@jupyterlab/fileeditor.FileEditor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。