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 undo a push', () => {
const list = new ObservableUndoableList(serializer);
list.push(serializer.fromJSON(value));
list.undo();
expect(list.length).to.equal(0);
});
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 dispose of the resources used by the list', () => {
const list = new ObservableUndoableList(serializer);
list.dispose();
expect(list.isDisposed).to.equal(true);
list.dispose();
expect(list.isDisposed).to.equal(true);
});
});
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);
});
it('should return false if there is no history', () => {
const list = new ObservableUndoableList(serializer);
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 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 clear the undo stack', () => {
const list = new ObservableUndoableList(serializer);
list.push(serializer.fromJSON(value));
list.clearUndo();
expect(list.canUndo).to.equal(false);
});
});
it('should undo a remove', () => {
const list = new ObservableUndoableList(serializer);
list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
list.remove(0);
list.undo();
expect(list.length).to.equal(2);
});
it('should redo a pushAll', () => {
const list = new ObservableUndoableList(serializer);
list.pushAll([serializer.fromJSON(value), serializer.fromJSON(value)]);
list.undo();
list.redo();
expect(list.length).to.equal(2);
});