當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript rendermime.MimeModel類代碼示例

本文整理匯總了TypeScript中@jupyterlab/rendermime.MimeModel的典型用法代碼示例。如果您正苦於以下問題:TypeScript MimeModel類的具體用法?TypeScript MimeModel怎麽用?TypeScript MimeModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MimeModel類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('should dispose of the resources used by the model', () => {
   let model = new MimeModel();
   model.dispose();
   expect(model.isDisposed).to.be(true);
   model.dispose();
   expect(model.isDisposed).to.be(true);
 });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:7,代碼來源:mimemodel.spec.ts

示例2: describe

describe('rendermime/mimemodel', () => {

  let model: MimeModel;

  beforeEach(() => {
    model = new MimeModel();
  });

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

  describe('MimeModel', () => {

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

      it('should create a new mime model', () => {
        let model = new MimeModel();
        expect(model).to.be.a(MimeModel);
      });

      it('should accept arguments', () => {
        let model = new MimeModel({
          data: { 'foo': 1},
          trusted: true,
          metadata: { 'bar': 'baz' }
        });
        expect(model).to.be.a(MimeModel);
      });

    });

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

      it('should get the trusted state of the model', () => {
        let model = new MimeModel();
        expect(model.trusted).to.be(false);
        model = new MimeModel({ trusted: true });
        expect(model.trusted).to.be(true);
      });

    });

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

      it('should dispose of the resources used by the model', () => {
        let model = new MimeModel();
        model.dispose();
        expect(model.isDisposed).to.be(true);
        model.dispose();
        expect(model.isDisposed).to.be(true);
      });

    });

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

      it('should be the data observable map', () => {
        let model = new MimeModel({
          data: { 'bar': 'baz' }
        });
        expect(model.data.get('bar')).to.be('baz');
      });

    });

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

      it('should be the metadata observable map', () => {
        let model = new MimeModel({
          metadata: { 'bar': 'baz' }
        });
        expect(model.metadata.get('bar')).to.be('baz');
      });

    });

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

      it('should return the raw JSON values', () => {
        let model = new MimeModel();
        model.data.set('foo', 1);
        model.metadata.set('bar', 'baz');
        expect(JSONExt.deepEqual(model.toJSON(), {
          trusted: false,
          data: {'foo': 1 },
          metadata: {'bar': 'baz'}
        })).to.be(true);
      });

    });

  });

});
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:95,代碼來源:mimemodel.spec.ts

示例3: afterEach

 afterEach(() => {
   model.dispose();
 });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:3,代碼來源:mimemodel.spec.ts


注:本文中的@jupyterlab/rendermime.MimeModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。