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 redo a pushBack', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushBack(serializer.fromJSON(value));
vector.undo();
vector.redo();
expect(vector.length).to.be(1);
});
it('should clear the undo stack', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushBack(serializer.fromJSON(value));
vector.clearUndo();
expect(vector.canUndo).to.be(false);
});
it('should dispose of the resources used by the vector', () => {
let vector = new ObservableUndoableVector(serializer);
vector.dispose();
expect(vector.isDisposed).to.be(true);
vector.dispose();
expect(vector.isDisposed).to.be(true);
});
it('should not be undoable if isUndoAble is set to false', () => {
let vector = new ObservableUndoableVector(serializer);
vector.beginCompoundOperation(false);
vector.pushBack(serializer.fromJSON(value));
vector.pushBack(serializer.fromJSON(value));
vector.endCompoundOperation();
expect(vector.canUndo).to.be(false);
});
it('should return true if there is a change that can be undone', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushBack(serializer.fromJSON(value));
expect(vector.canUndo).to.be(true);
});
it('should undo a pushBack', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushBack(serializer.fromJSON(value));
vector.undo();
expect(vector.length).to.be(0);
});
it('should redo a remove', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushAll([serializer.fromJSON(value),
serializer.fromJSON(value)]);
vector.removeAt(0);
vector.undo();
vector.redo();
expect(vector.length).to.be(1);
});
it('should return true if there is an undo that can be redone', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushBack(new Test(value));
vector.undo();
expect(vector.canRedo).to.be(true);
});
it('should redo a pushAll', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushAll([serializer.fromJSON(value),
serializer.fromJSON(value)]);
vector.undo();
vector.redo();
expect(vector.length).to.be(2);
});
it('should undo a removeRange', () => {
let vector = new ObservableUndoableVector(serializer);
vector.pushAll([serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value)]);
vector.removeRange(1, 3);
vector.undo();
expect(vector.length).to.be(6);
});