How to use the @jupyterlab/testutils.isFulfilled function in @jupyterlab/testutils

To help you get started, we’ve selected a few @jupyterlab/testutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-services / src / kernel / comm.spec.ts View on Github external
[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);
      });
    });
github jupyterlab / jupyterlab / tests / test-services / src / utils.spec.ts View on Github external
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);
    });
github jupyterlab / jupyterlab / tests / test-services / src / utils.spec.ts View on Github external
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');
    });
  });