本文整理匯總了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
}
})
);
});
示例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 })
})
);
});