Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Should not be processed
{
header: { msg_type: "ignored" },
content: { data: { "text/html": "<marquee>wee</marquee>" } }
},
{
header: { msg_type: "update_display_data" },
content: {
data: { "text/plain": "i am text" },
transient: { display_id: "here" }
}
}
];
const channels = from(messages);
const action$ = ActionsObservable.of({
type: actions.LAUNCH_KERNEL_SUCCESSFUL,
payload: {
kernel: {
channels,
cwd: "/home/tester",
type: "websocket"
},
kernelRef: "fakeKernelRef",
contentRef: "fakeContentRef",
selectNextKernel: false
}
});
const epic = updateDisplayEpic(action$);
const responseActions = [];
epic(epicFn, dependencies) {
const action$ = ActionsObservable.of(this.currentAction);
const store = {
getState: () => this.state
};
epicFn(action$, store, dependencies)
.toArray() // buffers all emitted actions until your Epic naturally completes()
.subscribe(actions => {
// only run automatically the first one
actions.forEach((action, idx) =>
idx === 0 && this.action(() => action)
);
actions.shift()
this.epicActions = actions;
});
return this;
byRef: Immutable.Map({
"123": makeNotebookContentRecord()
})
},
kernels: {
byRef: Immutable.Map({
k1: {}
})
}
}
}
})
};
await gitInitEpic(
ActionsObservable.of(actions.gitInit({ contentRef })),
store
)
.pipe(toArray())
.subscribe(actions => {
expect(actions).to.deep.equal([
actions.gitInitSuccessful({ contentRef })
]);
done();
});
});
});
test("errors when file cant be read", async () => {
const action$ = ActionsObservable.of({
type: "CORE/FETCH_CONTENT",
payload: { filepath: "file" }
});
const responseActions = await fetchContentEpic(action$)
.pipe(toArray())
.toPromise();
expect(responseActions).toEqual([
{
payload: {
error: expect.anything(),
filepath: "file"
},
error: true,
type: "CORE/FETCH_CONTENT_FAILED"
it('given failed call, should return joke failed action', () => {
const action$ = ActionsObservable.of(actions.getJoke());
const apis = {
getJokeApi: () => throwError({
message: 'test',
}),
};
getJokeEpic(action$, null, apis)
.pipe(toArray())
.subscribe(actualActions => expect(actualActions).to.deep.equal([
actions.getJokeFailed('test'),
]));
});
});
contentRef: stateModule.makeNotebookContentRecord({
model: stateModule.makeDocumentRecord({
kernelRef: "oldKernelRef"
})
})
})
})
})
}),
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({
channels,
status: "not connected"
})
})
})
})
}),
app: {
notificationSystem: { addNotification: jest.fn() }
}
}
};
const action$ = ActionsObservable.of(
actions.sendExecuteRequest({
id: "id",
message: "test",
contentRef: "fakeContentRef"
})
);
const observable = createExecuteCellStream(
action$,
state$.value,
createMessage("execute_request"),
"id",
"fakeContentRef"
);
observable.pipe(toArray()).subscribe(
actions => {
const errors = actions.map(({ payload: { error } }) =>
})
})
})
}),
app: stateModule.makeAppRecord({
host: stateModule.makeJupyterHostRecord({
type: "jupyter",
token: "eh",
serverUrl: "http://localhost:8888/"
}),
notificationSystem: { addNotification: jest.fn() }
})
}
};
const action$ = ActionsObservable.of(actions.interruptKernel({}));
const responseActions = await coreEpics
.interruptKernelEpic(action$, store)
.pipe(toArray())
.toPromise();
expect(responseActions).toEqual([
{
type: "INTERRUPT_KERNEL_SUCCESSFUL",
payload: {}
}
]);
});
});
data: "DATA",
metadata: "0",
comm_id: "0123",
target_name: "daredevil",
target_module: "murdock"
},
buffers: new Uint8Array([])
};
const commMessage = {
header: { msg_type: "comm_msg" },
content: { data: "DATA", comm_id: "0123" },
buffers: new Uint8Array([])
};
const action = ActionsObservable.of(
actions.launchKernelSuccessful({
kernel: {
channels: of(commOpenMessage, commMessage) as Subject,
cwd: "/home/tester",
type: "websocket"
},
kernelRef: "fakeKernelRef",
contentRef: "fakeContentRef",
selectNextKernel: false
})
);
commListenEpic(action)
.pipe(toArray())
.subscribe(
actions => {
byRef: Immutable.Map({
"123": makeNotebookContentRecord()
})
},
kernels: {
byRef: Immutable.Map({
k1: {}
})
}
}
}
})
};
await gitAddEpic(
ActionsObservable.of(actions.gitAdd({ contentRef })),
store
)
.pipe(toArray())
.subscribe(actions => {
expect(actions).to.deep.equal([
actions.gitAddSuccessful({ contentRef })
]);
done();
});
});
});