it('should trigger a changed signal', () => { let called = false; let value = new ObservableString('full'); value.changed.connect((sender, args) => { expect(sender).to.be(value); expect(args.type).to.be('set'); expect(args.start).to.be(0); expect(args.end).to.be(0); expect(args.value).to.be(''); called = true; }); value.clear(); expect(called).to.be(true); });
it('should trigger a changed signal', () => { let called = false; let value = new ObservableString('one two two three'); value.changed.connect((sender, args) => { expect(sender).to.be(value); expect(args.type).to.be('remove'); expect(args.start).to.be(4); expect(args.end).to.be(8); expect(args.value).to.be('two '); called = true; }); value.remove(4,8); expect(called).to.be(true); });
it('should test whether the string is disposed', () => { let value = new ObservableString(); expect(value.isDisposed).to.be(false); value.dispose(); expect(value.isDisposed).to.be(true); });
it('should empty the string', () => { let value = new ObservableString('full'); value.clear(); expect(value.text.length).to.be(0); expect(value.text).to.be(''); });
it('should remove a substring from the string', () => { let value = new ObservableString('one two two three'); value.remove(4,8); expect(value.text).to.eql('one two three'); });
it('should insert an substring into the string at a specific index', () => { let value = new ObservableString('one three'); value.insert(4, 'two '); expect(value.text).to.eql('one two three'); });