Skip to content

Commit 735755e

Browse files
committed
Add a test case for #3
1 parent a39d104 commit 735755e

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/simple-undo.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,31 @@ describe('SimpleUndo', function() {
151151
});
152152

153153
});
154-
})
154+
155+
it('should reserve initial when undo position to be 0 and save', function() {
156+
var count = 0;
157+
var provider = function(done) {
158+
done(count++);
159+
}
160+
161+
var history = new SimpleUndo({
162+
provider: provider,
163+
maxLength: 3
164+
});
165+
166+
history.initialize('initial');
167+
history.save();
168+
history.save();
169+
history.save();
170+
history.undo();
171+
history.undo();
172+
history.undo();
173+
174+
history.canUndo().should.be.false;
175+
history.count().should.equal(3);
176+
history.save();
177+
history.stack.length.should.equal(2);
178+
history.stack[0].should.equal('initial');
179+
history.stack[1].should.equal(3);
180+
});
181+
})

0 commit comments

Comments
 (0)