export function loadNotebook(state, action) { const { data } = action; const fetchedNotebook = commutable.fromJS(data); return Object.assign({}, state, { notebook: fetchedNotebook, }); }
return (subject) => { const data = commutable.fromJS(nbData); subject.next({ type: constants.SET_NOTEBOOK, data, }); };
it('converts a JSON notebook to our commutable notebook and puts in state', () => { const initialState = { app: null, document: initialDocument, }; const data = fromJS(dummyJSON); const state = reducers(initialState, { type: constants.SET_NOTEBOOK, data }); expect(state.document.getIn(['notebook', 'nbformat'])).to.equal(4); });
fs.readFile(filename, {}, (err, data) => { if (err) { reject(err); console.warn('Filename not resolved, launching an empty Notebook.'); launchNewNotebook('python3'); } else { resolve(launch(fromJS(JSON.parse(data)), filename)); } });
it('converts a JSON notebook to our commutable notebook and puts in state', () => { const state = setNotebook({}, { data: fromJS(dummyJSON) }); expect(state.notebook.get('nbformat')).to.equal(4); });
it('converts a JSON notebook to our commutable notebook and puts in state', () => { const state = reducers({}, { type: constants.SET_NOTEBOOK, data: fromJS(dummyJSON) }); expect(state.document.notebook.get('nbformat')).to.equal(4); });
const NotebookPreview = (props) => { const nb = props.notebook; const notebook = Immutable.Map.isMap(nb) ? nb : commutable.fromJS(nb); return <Notebook notebook={notebook} />; };