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 return the index occupied by the item', () => {
const value = new ObservableList({ values: [1, 2, 3] });
expect(value.removeValue(1)).to.equal(0);
});
it('should return the new length of the list', () => {
const value = new ObservableList({ values: [1] });
expect(value.pushAll([2, 3, 4])).to.equal(4);
});
it('should dispose of the resources held by the list', () => {
const value = new ObservableList({ values: [1, 2, 3] });
value.dispose();
expect(value.isDisposed).to.equal(true);
});
});
it('should push an array of items to the end of the list', () => {
const value = new ObservableList({ values: [1] });
value.pushAll([2, 3, 4]);
expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
});
it('should remove all items from the list', () => {
const values = [1, 2, 3, 4, 5, 6];
const value = new ObservableList({ values });
value.clear();
expect(value.length).to.equal(0);
value.clear();
expect(value.length).to.equal(0);
});
it('should push an array of items into a list', () => {
const value = new ObservableList({ values: [1, 2, 3] });
value.insertAll(1, [2, 3, 4]);
expect(toArray(value)).to.deep.equal([1, 2, 3, 4, 2, 3]);
});
it('should trigger a changed signal', () => {
let called = false;
const value = new ObservableList({ values: [1, 2, 3] });
value.changed.connect((sender, args) => {
expect(sender).to.equal(value);
expect(args.type).to.equal('add');
expect(args.newIndex).to.equal(3);
expect(args.oldIndex).to.equal(-1);
expect(toArray(args.newValues)).to.deep.equal([4, 5, 6]);
expect(args.oldValues.length).to.equal(0);
called = true;
});
value.pushAll([4, 5, 6]);
expect(called).to.equal(true);
});
});
it('should insert an item into the list at a specific index', () => {
const value = new ObservableList({ values: [1, 2, 3] });
value.insert(1, 4);
expect(toArray(value)).to.deep.equal([1, 4, 2, 3]);
});
it('should get the value at the specified index', () => {
const value = new ObservableList({ values: [1, 2, 3] });
expect(value.get(1)).to.equal(2);
});
});
it('should add an item to the end of the list', () => {
const value = new ObservableList({ values: [1, 2, 3] });
value.push(4);
expect(toArray(value)).to.deep.equal([1, 2, 3, 4]);
});