How to use the @jupyterlab/observables.ObservableJSON function in @jupyterlab/observables

To help you get started, we’ve selected a few @jupyterlab/observables 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-data-explorer / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should update the text area value', () => {
        let model = editor.model;
        expect(model.value.text).to.equal('No data!');
        editor.source = new ObservableJSON();
        expect(model.value.text).to.equal('{}');
      });
    });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should bail if the input is focused', () => {
        Widget.attach(editor, document.body);
        editor.model.value.text = '{}';
        editor.source = new ObservableJSON();
        editor.editor.focus();
        editor.source.set('foo', 2);
        expect(editor.model.value.text).to.equal('{}');
      });
    });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should allow a key to be removed programmatically that was not set by the user', () => {
          editor.source = new ObservableJSON();
          editor.source.set('foo', 1);
          editor.source.set('bar', 1);
          editor.model.value.text = '{"foo": 1, "bar": 3}';
          editor.source.delete('foo');
          simulate(editor.commitButtonNode, 'click');
          expect(editor.model.value.text).to.equal('{\n    "bar": 3\n}');
        });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablejson.spec.ts View on Github external
it('should serialize the model to JSON', () => {
        const item = new ObservableJSON();
        item.set('foo', 1);
        expect(item.toJSON()['foo']).to.equal(1);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should revert the current data', () => {
          editor.source = new ObservableJSON();
          editor.model.value.text = 'foo';
          simulate(editor.revertButtonNode, 'click');
          expect(editor.model.value.text).to.equal('{}');
        });
github jupyterlab / jupyterlab-data-explorer / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should bail if the input is focused', () => {
        Widget.attach(editor, document.body);
        editor.model.value.text = '{}';
        editor.source = new ObservableJSON();
        editor.editor.focus();
        editor.source.set('foo', 2);
        expect(editor.model.value.text).to.equal('{}');
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should allow a key to be removed programmatically that was not set by the user', () => {
          editor.source = new ObservableJSON();
          editor.source.set('foo', 1);
          editor.source.set('bar', 1);
          editor.model.value.text = '{"foo": 1, "bar": 3}';
          editor.source.delete('foo');
          simulate(editor.commitButtonNode, 'click');
          expect(editor.model.value.text).to.equal('{\n    "bar": 3\n}');
        });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should not revert to current data if there was a change', () => {
          editor.source = new ObservableJSON();
          editor.model.value.text = 'foo';
          editor.source.set('foo', 1);
          let model = editor.model;
          expect(model.value.text).to.equal('foo');
          simulate(editor.editorHostNode, 'blur');
          expect(model.value.text).to.equal('foo');
          expect(editor.commitButtonNode.hidden).to.be.true;
          expect(editor.revertButtonNode.hidden).to.be.false;
        });
      });
github jupyterlab / jupyterlab / tests / test-codeeditor / src / jsoneditor.spec.ts View on Github external
it('should be settable', () => {
        let source = new ObservableJSON();
        editor.source = source;
        expect(editor.source).to.equal(source);
      });
github jupyterlab / jupyterlab-data-explorer / tests / test-observables / src / observablejson.spec.ts View on Github external
it('should return a copy of the data', () => {
        const item = new ObservableJSON();
        item.set('foo', { bar: 1 });
        const value = item.toJSON();
        value['bar'] = 2;
        expect((item.get('foo') as any)['bar']).to.equal(1);
      });
    });