test("detects a cell execution keypress", () => { const focusedCell = dummyCommutable.getIn(["cellOrder", 1]); const context = { store: dummyStore() }; context.store.dispatch = jest.fn(); const executeFocusedCell = jest.fn(); const component = shallow( <NotebookApp cellOrder={dummyCommutable.get("cellOrder")} cellMap={dummyCommutable.get("cellMap")} transient={new Immutable.Map({ cellMap: new Immutable.Map() })} cellPagers={new Immutable.Map()} cellStatuses={dummyCellStatuses} cellFocused={focusedCell} executeFocusedCell={executeFocusedCell} />, { context } ); const inst = component.instance(); const evt = new window.CustomEvent("keydown"); evt.ctrlKey = true; evt.keyCode = 13; inst.keyDown(evt); expect(executeFocusedCell).toHaveBeenCalled(); });
test("accepts an Immutable.List of cells", () => { const component = shallow( <NotebookApp cellOrder={dummyCommutable.get("cellOrder")} cellMap={dummyCommutable.get("cellMap")} transient={new Immutable.Map({ cellMap: new Immutable.Map() })} cellPagers={new Immutable.Map()} cellStatuses={new Immutable.Map()} /> ); expect(component).not.toBeNull(); });
test("edits gist that is already made", done => { const github = GitHub(); const store = dummyStore(); const notebook = dummyCommutable.setIn(["metadata", "gist_id"], "ID123"); const notificationSystem = createNotificationSystem(); const publishNotebookObs = publishNotebookObservable( github, notebook, "./test.ipynb", notificationSystem, false, store ); const edit = jest.spyOn(github.gists, "edit"); publishNotebookObs.subscribe( x => { expect(x.type).toBe("OVERWRITE_METADATA_FIELD"); }, done.fail, () => { expect(edit).toHaveBeenCalled(); done(); } ); });
/* eslint-disable max-len */ import React from "react"; import Immutable from "immutable"; import { Provider } from "react-redux"; import { shallow, mount } from "enzyme"; import renderer from "react-test-renderer"; import { displayOrder, transforms } from "@nteract/transforms"; import { NotebookApp } from "../src/notebook-app"; import { dummyStore, dummyCommutable } from "@nteract/core/dummy"; const dummyCellStatuses = dummyCommutable .get("cellOrder") .reduce( (statuses, cellID) => statuses.set( cellID, Immutable.fromJS({ outputHidden: false, inputHidden: false }) ), new Immutable.Map() ); // Boilerplate test to make sure the testing setup is configured describe("NotebookApp", () => { test("accepts an Immutable.List of cells", () => { const component = shallow( <NotebookApp cellOrder={dummyCommutable.get("cellOrder")} cellMap={dummyCommutable.get("cellMap")}