Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[Kernel.IComm, KernelMessage.ICommOpenMsg]
>();
const hook = (comm: Kernel.IComm, msg: KernelMessage.ICommOpenMsg) => {
promise.resolve([comm, msg]);
};
const kernel2 = await Kernel.startNew({
name: 'ipython',
handleComms: false
});
kernel2.registerCommTarget('test', hook);
// Request the comm creation.
await kernel2.requestExecute({ code: SEND }, true).done;
// The promise above should not be fulfilled, even after a short delay.
expect(await isFulfilled(promise.promise, 300)).to.be.false;
// The kernel comm has not been closed - we just completely ignored it.
let reply = await kernel2.requestExecute(
{ code: `assert comm._closed is False` },
true
).done;
// If the assert was false, we would get an 'error' status
expect(reply.content.status).to.equal('ok');
// Clean up
kernel2.removeCommTarget('test', hook);
});
});
it('should resolve to true only after a promise is fulfilled', async () => {
const p = new PromiseDelegate();
expect(await isFulfilled(p.promise)).to.equal(false);
p.resolve(10);
expect(await isFulfilled(p.promise)).to.equal(true);
});
it('should resolve if the test succeeds', async () => {
const owner = {};
const x = new Signal<{}, number>(owner);
const emission = testEmission(x, {
find: (a, b) => b === 1,
test: (a, b) => {
expect(b).to.equal(1);
},
value: 'done'
});
x.emit(0);
expect(await isFulfilled(emission)).to.equal(false);
x.emit(1);
expect(await emission).to.equal('done');
});
});