aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-state-history-helper.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-10-03 06:23:27 +0800
committerGitHub <noreply@github.com>2017-10-03 06:23:27 +0800
commit4b0e6a0a778efa24e6bbca1e9b60171606d46d2f (patch)
treeb5d338f9a9458a4cc3ff50abc0790823aac4b901 /test/unit/tx-state-history-helper.js
parente998d528f0af71d1163bc89fe9e81195bb4f5dc3 (diff)
parentb7c195160238119291ce62b01db1c8f7e4f94568 (diff)
downloadtangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar.gz
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar.bz2
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar.lz
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar.xz
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.tar.zst
tangerine-wallet-browser-4b0e6a0a778efa24e6bbca1e9b60171606d46d2f.zip
Merge branch 'master' into RemoveSlackLink
Diffstat (limited to 'test/unit/tx-state-history-helper.js')
-rw-r--r--test/unit/tx-state-history-helper.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/tx-state-history-helper.js b/test/unit/tx-state-history-helper.js
index 5bb6c9bee..79ee26d6e 100644
--- a/test/unit/tx-state-history-helper.js
+++ b/test/unit/tx-state-history-helper.js
@@ -20,4 +20,27 @@ describe('tx-state-history-helper', function () {
})
})
})
+
+ it('replaying history does not mutate the original obj', function () {
+ const initialState = { test: true, message: 'hello', value: 1 }
+ const diff1 = [{
+ "op": "replace",
+ "path": "/message",
+ "value": "haay",
+ }]
+ const diff2 = [{
+ "op": "replace",
+ "path": "/value",
+ "value": 2,
+ }]
+ const history = [initialState, diff1, diff2]
+
+ const beforeStateSnapshot = JSON.stringify(initialState)
+ const latestState = txStateHistoryHelper.replayHistory(history)
+ const afterStateSnapshot = JSON.stringify(initialState)
+
+ assert.notEqual(initialState, latestState, 'initial state is not the same obj as the latest state')
+ assert.equal(beforeStateSnapshot, afterStateSnapshot, 'initial state is not modified during run')
+ })
+
})