How to use the @jupyterlab/testutils.signalToPromise 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-statedb / src / restorablepool.spec.ts View on Github external
it('should emit when an instance has been added', async () => {
        const instance = new ObservableDisposable();
        const promise = signalToPromise(pool.added);
        await pool.add(instance);
        const [sender, args] = await promise;
        expect(sender).to.equal(pool);
        expect(args).to.equal(instance);
        instance.dispose();
      });
    });
github jupyterlab / jupyterlab / tests / test-docmanager / src / savehandler.spec.ts View on Github external
it('should trigger a save', () => {
        let promise = signalToPromise(context.fileChanged);
        context.model.fromString('bar');
        expect(handler.isActive).to.equal(false);
        handler.saveInterval = 1;
        handler.start();
        return promise;
      });
github jupyterlab / jupyterlab / tests / test-apputils / src / widgettracker.spec.ts View on Github external
it('should emit when the current widget has been updated', async () => {
        const widget = createWidget();
        let promise = signalToPromise(tracker.currentChanged);

        Widget.attach(widget, document.body);
        focus(widget);
        void tracker.add(widget);
        await promise;
        widget.dispose();
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-notebook / src / default-toolbar.spec.ts View on Github external
it('should save when clicked', async () => {
        const button = ToolbarItems.createSaveButton(panel);
        Widget.attach(button, document.body);
        let promise = signalToPromise(context.fileChanged);
        await framePromise();
        simulate(button.node.firstChild as HTMLElement, 'mousedown');
        await promise;
        button.dispose();
      });
github jupyterlab / jupyterlab / tests / test-filebrowser / src / crumbs.spec.ts View on Github external
it('should switch to the grandparent directory', async () => {
          Widget.attach(crumbs, document.body);
          MessageLoop.sendMessage(crumbs, Widget.Msg.UpdateRequest);
          let items = crumbs.node.querySelectorAll(ITEM_QUERY);
          const promise = signalToPromise(model.pathChanged);
          simulate(items[1], 'click');
          await promise;
          MessageLoop.sendMessage(crumbs, Widget.Msg.UpdateRequest);
          items = crumbs.node.querySelectorAll(ITEM_QUERY);
          expect(items.length).to.equal(2);
          expect(model.path).to.equal(first);
        });
github jupyterlab / jupyterlab-data-explorer / tests / test-coreutils / src / settingregistry.spec.ts View on Github external
it('should emit when a plugin changes', async () => {
        const id = 'alpha';
        const schema: ISettingRegistry.ISchema = { type: 'object' };

        connector.schemas[id] = schema;
        settings = (await registry.load(id)) as Settings;
        let promise = signalToPromise(settings.changed);
        await settings.set('foo', 'bar');
        await promise;
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-notebook / src / widget.spec.ts View on Github external
it('should add a new default cell when cells are cleared', async () => {
          const model = widget.model;
          widget.notebookConfig = {
            ...widget.notebookConfig,
            defaultCell: 'raw'
          };
          let promise = signalToPromise(model.cells.changed);
          model.cells.clear();
          await promise;
          expect(model.cells.length).to.equal(0);
          await signalToPromise(model.cells.changed);
          expect(model.cells.length).to.equal(1);
          expect(model.cells.get(0)).to.be.an.instanceof(RawCellModel);
        });
      });
github jupyterlab / jupyterlab / tests / test-console / src / history.spec.ts View on Github external
it('should be called upon an editor edge request', async () => {
        const history = new TestHistory({ session });
        expect(history.methods).to.not.contain('onEdgeRequest');
        const host = document.createElement('div');
        const model = new CodeEditor.Model();
        const editor = new CodeMirrorEditor({ model, host });
        history.editor = editor;
        history.push('foo');
        const promise = signalToPromise(editor.model.value.changed);
        editor.edgeRequested.emit('top');
        expect(history.methods).to.contain('onEdgeRequest');
        await promise;
        expect(editor.model.value.text).to.equal('foo');
      });
    });
github jupyterlab / jupyterlab / tests / test-notebook / src / default-toolbar.spec.ts View on Github external
it('should save when clicked', async () => {
          const button = ToolbarItems.createSaveButton(panel);
          Widget.attach(button, document.body);
          let promise = signalToPromise(context.fileChanged);
          await framePromise();
          simulate(button.node.firstChild as HTMLElement, 'mousedown');
          await promise;
          button.dispose();
        });
github jupyterlab / jupyterlab / tests / test-notebook / src / widget.spec.ts View on Github external
it('should add a new default cell when cells are cleared', async () => {
          const model = widget.model!;
          widget.notebookConfig = {
            ...widget.notebookConfig,
            defaultCell: 'raw'
          };
          let promise = signalToPromise(model.cells.changed);
          model.cells.clear();
          await promise;
          expect(model.cells.length).to.equal(0);
          await signalToPromise(model.cells.changed);
          expect(model.cells.length).to.equal(1);
          expect(model.cells.get(0)).to.be.an.instanceof(RawCellModel);
        });
      });