How to use the @jupyterlab/completer/src.CompleterModel function in @jupyterlab/completer

To help you get started, we’ve selected a few @jupyterlab/completer 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 yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should return undefined if original request or cursor are null', () => {
        let model = new CompleterModel();
        expect(model.createPatch('foo')).to.be.undefined;
      });
github yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should reset model if change is shorter than original', () => {
        let model = new CompleterModel();
        let currentValue = 'foo';
        let newValue = 'fo';
        let cursor: Completer.ICursorSpan = { start: 0, end: 0 };
        let request = makeState(currentValue);
        let change = makeState(newValue);
        model.original = request;
        model.cursor = cursor;
        model.current = change;
        expect(model.current).to.be.null;
        expect(model.original).to.be.null;
        expect(model.options().next()).to.be.undefined;
      });
    });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should be safe to reset', () => {
        let model = new CompleterModel();
        let widget = new Completer({
          editor: null,
          model: new CompleterModel()
        });
        expect(widget.model).not.to.equal(model);
        widget.model = model;
        expect(widget.model).to.equal(model);
      });
    });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should trigger a selected signal on mouse down', () => {
          let anchor = createEditorWidget();
          let model = new CompleterModel();
          let options: Completer.IOptions = {
            editor: anchor.editor,
            model
          };
          let value = '';
          let listener = (sender: any, selected: string) => {
            value = selected;
          };
          model.setOptions(['foo', 'bar', 'baz'], {
            foo: 'instance',
            bar: 'function'
          });
          model.query = 'b';
          Widget.attach(anchor, document.body);

          let widget = new Completer(options);
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should emit a signal when an item is selected', () => {
        let anchor = createEditorWidget();
        let options: Completer.IOptions = {
          editor: anchor.editor,
          model: new CompleterModel()
        };
        let value = '';
        let listener = (sender: any, selected: string) => {
          value = selected;
        };
        options.model.setOptions(['foo', 'bar']);
        Widget.attach(anchor, document.body);

        let widget = new Completer(options);

        widget.selected.connect(listener);
        Widget.attach(widget, document.body);
        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
        expect(value).to.equal('');
        widget.selectActive();
        expect(value).to.equal('foo');
github yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should be true if model has been disposed', () => {
        let model = new CompleterModel();
        expect(model.isDisposed).to.equal(false);
        model.dispose();
        expect(model.isDisposed).to.equal(true);
      });
    });
github yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should not signal when options have not changed', () => {
        let model = new CompleterModel();
        let called = 0;
        let listener = (sender: any, args: void) => {
          called++;
        };
        model.stateChanged.connect(listener);
        expect(called).to.equal(0);
        model.setOptions(['foo']);
        model.setOptions(['foo']);
        expect(called).to.equal(1);
        model.setOptions(['foo'], { foo: 'instance' });
        model.setOptions(['foo'], { foo: 'instance' });
        expect(called).to.equal(2);
        model.setOptions([], {});
        model.setOptions([], {});
        expect(called).to.equal(3);
      });
github yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should set current change value', () => {
        let model = new CompleterModel();
        let currentValue = 'foo';
        let newValue = 'foob';
        let cursor: Completer.ICursorSpan = { start: 0, end: 0 };
        let request = makeState(currentValue);
        let change = makeState(newValue);
        (change as any).column = 4;
        model.original = request;
        model.cursor = cursor;
        expect(model.current).to.equal(request);
        model.handleTextChange(change);
        expect(model.current).to.equal(change);
      });
github yuvipanda / simplest-notebook / tests / test-completer / src / model.spec.ts View on Github external
it('should default to null', () => {
        let model = new CompleterModel();
        expect(model.cursor).to.be.null;
      });
github jupyterlab / jupyterlab / tests / test-completer / src / widget.spec.ts View on Github external
it('should be safe to reset', () => {
        let model = new CompleterModel();
        let widget = new Completer({
          editor: null,
          model: new CompleterModel()
        });
        expect(widget.model).not.to.equal(model);
        widget.model = model;
        expect(widget.model).to.equal(model);
      });
    });