Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should accept no arguments', () => {
const value = new ObservableValue();
expect(value instanceof ObservableValue).to.equal(true);
expect(value.get()).to.be.null;
});
it('should accept an initial JSON value', () => {
const value = new ObservableValue('value');
expect(value instanceof ObservableValue).to.equal(true);
const value2 = new ObservableValue({ one: 'one', two: 2 });
expect(value2 instanceof ObservableValue).to.equal(true);
});
});
it('should return `Value`', () => {
const value = new ObservableValue();
expect(value.type).to.equal('Value');
});
});
it('should get the value of the object', () => {
const value = new ObservableValue('value');
expect(value.get()).to.equal('value');
const value2 = new ObservableValue({ one: 'one', two: 2 });
expect(
JSONExt.deepEqual(value2.get(), { one: 'one', two: 2 })
).to.equal(true);
});
});
it('should test whether the value is disposed', () => {
const value = new ObservableValue();
expect(value.isDisposed).to.equal(false);
value.dispose();
expect(value.isDisposed).to.equal(true);
});
});
it('should get the value of the object', () => {
const value = new ObservableValue('value');
expect(value.get()).to.equal('value');
const value2 = new ObservableValue({ one: 'one', two: 2 });
expect(
JSONExt.deepEqual(value2.get(), { one: 'one', two: 2 })
).to.equal(true);
});
});
it('should accept an initial JSON value', () => {
const value = new ObservableValue('value');
expect(value instanceof ObservableValue).to.equal(true);
const value2 = new ObservableValue({ one: 'one', two: 2 });
expect(value2 instanceof ObservableValue).to.equal(true);
});
});
it('should have value changed args', () => {
let called = false;
const value = new ObservableValue();
value.changed.connect((sender, args) => {
expect(sender).to.equal(value);
expect(args.newValue).to.equal('set');
expect(args.oldValue).to.be.null;
called = true;
});
value.set('set');
expect(called).to.equal(true);
});
});
it('should be emitted when the map changes state', () => {
let called = false;
const value = new ObservableValue();
value.changed.connect(() => {
called = true;
});
value.set('set');
expect(called).to.equal(true);
});
constructor(initialName: string = '', placeholder?: string) {
super();
this._nameNode = document.createElement('div');
this._editNode = document.createElement('input');
this._placeholder = placeholder || '';
this.node.appendChild(this._nameNode);
this.name = new ObservableValue(initialName);
this._nameNode.textContent = initialName || this._placeholder;
this.node.onclick = () => {
if (this._pending) {
return;
}
this._pending = true;
Private.changeField(this._nameNode, this._editNode).then(value => {
this._pending = false;
if (this.name.get() !== value) {
this.name.set(value);
}
});
};
this.name.changed.connect((s, args) => {