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


TypeScript commutable.emptyCodeCell類代碼示例

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


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

示例1: test

  test("copies a cell", () => {
    const firstId = uuid();
    const secondId = uuid();
    const thirdId = uuid();

    const originalState = makeDocumentRecord({
      notebook: Immutable.fromJS({
        cellOrder: [firstId, secondId, thirdId],
        cellMap: {
          [firstId]: emptyCodeCell.set("source", "data"),
          [secondId]: emptyCodeCell,
          [thirdId]: emptyCodeCell
        }
      }),
      cellFocused: secondId,
      copied: null
    });

    const state = reducers(originalState, actions.copyCell({ id: firstId }));

    expect(state.get("copied")).toEqual(emptyCodeCell.set("source", "data"));

    expect(state.get("notebook")).toEqual(
      Immutable.fromJS({
        cellOrder: [firstId, secondId, thirdId],
        cellMap: {
          [firstId]: emptyCodeCell.set("source", "data"),
          [secondId]: emptyCodeCell,
          [thirdId]: emptyCodeCell
        }
      })
    );
  });
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:33,代碼來源:document.spec.ts

示例2: test

  test("updates the metadata of an output by cell ID & index", () => {
    const originalState = monocellDocument.set(
      "notebook",
      appendCellToNotebook(
        fixtureCommutable,
        emptyCodeCell.set("outputs", Immutable.fromJS([{ empty: "output" }]))
      )
    );

    const newOutputMetadata = Immutable.Map({ meta: "data" });

    const id: string = originalState.getIn(["notebook", "cellOrder"]).last();

    const state = reducers(
      originalState,
      actions.updateOutputMetadata({
        id,
        metadata: newOutputMetadata,
        index: 0,
        mediaType: "test/mediatype"
      })
    );
    expect(state.getIn(["notebook", "cellMap", id, "outputs", 0])).toEqual(
      Immutable.Map({
        empty: "output",
        metadata: Immutable.Map({ "test/mediatype": newOutputMetadata })
      })
    );
  });
開發者ID:nteract,項目名稱:nteract,代碼行數:29,代碼來源:document.spec.ts


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