diff options
author | Frankie <frankie.diamond@gmail.com> | 2017-10-03 04:41:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 04:41:56 +0800 |
commit | bf390bd63d7642d5a4975c572eb928252122a79b (patch) | |
tree | 245a50b36ef9dab402b5b87da09f39899dcf98c6 /test | |
parent | da4b790034f599f63e3507e4394d456bd3add47c (diff) | |
parent | d29b5f10ef5137ab56ecc9615e5e894082db9803 (diff) | |
download | tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar.gz tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar.bz2 tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar.lz tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar.xz tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.tar.zst tangerine-wallet-browser-bf390bd63d7642d5a4975c572eb928252122a79b.zip |
Merge pull request #2259 from MetaMask/tx-history-fix
tx state history - fix bug where initial snapshot was mutated on updateTx
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/tx-state-history-helper.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/tx-state-history-helper.js b/test/unit/tx-state-history-helper.js index 5bb6c9bee..e5075af88 100644 --- a/test/unit/tx-state-history-helper.js +++ b/test/unit/tx-state-history-helper.js @@ -20,4 +20,26 @@ 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') + }) }) |