From a30571ee422b9ad4e96d8e0f31f1d66581afecdf Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijnh@gmail.com> Date: Thu, 19 Jul 2012 13:28:42 +0200 Subject: [PATCH] [test] Make sure set/getHistory keep working --- test/test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test.js b/test/test.js index 35b68cac0..9999dc312 100644 --- a/test/test.js +++ b/test/test.js @@ -359,3 +359,22 @@ testCM("selectionPos", function(cm) { } is(sawTop && sawBottom && sawMiddle, "all parts"); }); + +testCM("restoreHistory", function(cm) { + cm.setValue("abc\ndef"); + cm.compoundChange(function() {cm.setLine(1, "hello");}); + cm.compoundChange(function() {cm.setLine(0, "goop");}); + cm.undo(); + var storedVal = cm.getValue(), storedHist = cm.getHistory(); + if (window.JSON) storedHist = JSON.parse(JSON.stringify(storedHist)); + eq(storedVal, "abc\nhello"); + cm.setValue(""); + cm.clearHistory(); + eq(cm.historySize().undo, 0); + cm.setValue(storedVal); + cm.setHistory(storedHist); + cm.redo(); + eq(cm.getValue(), "goop\nhello"); + cm.undo(); cm.undo(); + eq(cm.getValue(), "abc\ndef"); +}); -- GitLab