Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async getInitialProps({ store, isServer }) {
const state$ = new StateObservable(new Subject(), store.getState())
const resultAction = await rootEpic(
of(actions.fetchCharacter(isServer)),
state$
).toPromise() // we need to convert Observable to Promise
store.dispatch(resultAction)
return { isServer }
}
})
)
}),
transforms: makeTransformsRecord({
displayOrder: Immutable.List([]),
byId: Immutable.Map({})
})
})
})
};
const responses = await saveAsContentEpic(
ActionsObservable.of(
actions.saveAs({ filepath: "test.ipynb", contentRef })
),
new StateObservable(new Subject(), state)
)
.pipe(toArray())
.toPromise();
expect(responses).toEqual([
actions.saveAsFailed({
contentRef,
error: new Error("Cannot save content if no host is set.")
})
]);
});
it("does not save if there is no content", async () => {
test("can interrupt a kernel when given a content ref", async () => {
const state$ = new StateObservable(new Subject(), {
core: stateModule.makeStateRecord({
entities: stateModule.makeEntitiesRecord({
kernels: stateModule.makeKernelsRecord({
byRef: Immutable.Map({
fakeKernelRef: stateModule.makeRemoteKernelRecord({
type: "websocket",
channels: new Subject(),
kernelSpecName: "fancy",
id: "0"
})
})
}),
contents: stateModule.makeContentsRecord({
byRef: Immutable.Map({
contentRef: stateModule.makeNotebookContentRecord({
model: stateModule.makeDocumentRecord({
test("respects output handling for running all cells", async () => {
const state$ = new StateObservable(new Subject(), {
core: stateModule.makeStateRecord({
kernelRef: "fake",
entities: stateModule.makeEntitiesRecord({
kernels: stateModule.makeKernelsRecord({
byRef: Immutable.Map({
fake: stateModule.makeRemoteKernelRecord({
type: "websocket",
channels: new Subject(),
kernelSpecName: "fancy",
id: "0"
})
})
})
})
}),
app: stateModule.makeAppRecord({
})
}),
app: stateModule.makeAppRecord({
notificationSystem: { addNotification: () => {} }
})
};
const responses = await restartKernelEpic(
ActionsObservable.of(
actionsModule.restartKernel({
outputHandling: "Run All",
kernelRef: "oldKernelRef",
contentRef: "contentRef"
})
),
new StateObservable(new Subject(), state)
)
.pipe(toArray())
.toPromise();
expect(responses).toEqual([]);
});
});
})
}),
kernels: stateModule.makeKernelsRecord({
byRef: Immutable.Map({
fake: stateModule.makeRemoteKernelRecord({
type: "websocket",
channels: new Subject(),
kernelSpecName: "fancy",
id: "0"
})
})
})
})
})
};
const state$ = new StateObservable(
new Subject(),
value
);
const action$ = ActionsObservable.of(
actions.launchKernelByName({
contentRef,
kernelRef,
kernelSpecName: "fancy",
cwd: "/",
selectNextKernel: true
})
);
const responseActions = await coreEpics
.launchWebSocketKernelEpic(action$, state$)
.pipe(toArray())
})
)
}),
transforms: makeTransformsRecord({
displayOrder: Immutable.List([]),
byId: Immutable.Map({})
})
})
})
};
const responses = await saveContentEpic(
ActionsObservable.of(
actions.save({ filepath: "test.ipynb", contentRef })
),
new StateObservable(new Subject(), state)
)
.pipe(toArray())
.toPromise();
expect(responses).toEqual([
actions.saveFulfilled({
contentRef,
model: { last_modified: "one_value" }
}),
actions.saveFulfilled({
contentRef,
model: { last_modified: "some_stable_value" }
})
]);
});
});
static async getInitialProps (pageProps) {
const { store } = pageProps
const store$ = new StateObservable(new Subject(), store.getState())
const action = await epics(
of(fetchGithub()),
store$
)
.toPromise()
store.dispatch(action)
return { }
}