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 removeRange', () => {
const list = new ObservableUndoableList(serializer);
list.pushAll([
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value)
]);
list.removeRange(1, 3);
list.undo();
list.redo();
expect(list.length).to.equal(4);
});
it('should clear the undo stack', () => {
const list = new ObservableUndoableList(serializer);
list.push(serializer.fromJSON(value));
list.clearUndo();
expect(list.canUndo).to.equal(false);
});
});
it('should begin a compound operation', () => {
const list = new ObservableUndoableList(serializer);
list.beginCompoundOperation();
list.push(serializer.fromJSON(value));
list.push(serializer.fromJSON(value));
list.endCompoundOperation();
expect(list.canUndo).to.equal(true);
list.undo();
expect(list.canUndo).to.equal(false);
});
it('should redo a remove', () => {
const list = new ObservableUndoableList(serializer);
list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
list.remove(0);
list.undo();
list.redo();
expect(list.length).to.equal(1);
});
it('should undo a push', () => {
const list = new ObservableUndoableList(serializer);
list.push(serializer.fromJSON(value));
list.undo();
expect(list.length).to.equal(0);
});
it('should create a new ObservableUndoableList', () => {
const list = new ObservableUndoableList(serializer);
expect(list).to.be.an.instanceof(ObservableUndoableList);
});
});
it('should not be undoable if isUndoAble is set to false', () => {
const list = new ObservableUndoableList(serializer);
list.beginCompoundOperation(false);
list.push(serializer.fromJSON(value));
list.push(serializer.fromJSON(value));
list.endCompoundOperation();
expect(list.canUndo).to.equal(false);
});
});
it('should return true if there is an undo that can be redone', () => {
const list = new ObservableUndoableList(serializer);
list.push(new Test(value));
list.undo();
expect(list.canRedo).to.equal(true);
});
});
it('should undo a move', () => {
const items = [
serializer.fromJSON(value),
serializer.fromJSON(value),
serializer.fromJSON(value)
];
const list = new ObservableUndoableList(serializer);
list.pushAll(items);
list.move(1, 2);
list.undo();
expect((list.get(1) as any)['count']).to.equal(
(items[1] as any)['count']
);
});
});
it('should redo a push', () => {
const list = new ObservableUndoableList(serializer);
list.push(serializer.fromJSON(value));
list.undo();
list.redo();
expect(list.length).to.equal(1);
});