aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-08-29 03:04:54 +0800
committerGitHub <noreply@github.com>2017-08-29 03:04:54 +0800
commit71de68fc13d83934e8bc81ba43574a946bc32159 (patch)
treec51d9cfbbe028276d4fa18821f00d5ed5869e585
parenta812c02ed7f4882e4fa039bb5f9767b42ea8992d (diff)
parentb97a65e1d1e421a09bc219167de189e0a6d2e340 (diff)
downloadtangerine-wallet-browser-71de68fc13d83934e8bc81ba43574a946bc32159.tar.gz
tangerine-wallet-browser-71de68fc13d83934e8bc81ba43574a946bc32159.tar.zst
tangerine-wallet-browser-71de68fc13d83934e8bc81ba43574a946bc32159.zip
Merge pull request #1985 from MetaMask/i1974-EnsureDeepCloneHistory
Add some tests to tx-state-history-helper
-rw-r--r--test/unit/tx-state-history-helper-test.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/tx-state-history-helper-test.js b/test/unit/tx-state-history-helper-test.js
new file mode 100644
index 000000000..90cb10713
--- /dev/null
+++ b/test/unit/tx-state-history-helper-test.js
@@ -0,0 +1,26 @@
+const assert = require('assert')
+const clone = require('clone')
+const txStateHistoryHelper = require('../../app/scripts/lib/tx-state-history-helper')
+
+describe('deepCloneFromTxMeta', function () {
+ it('should clone deep', function () {
+ const input = {
+ foo: {
+ bar: {
+ bam: 'baz'
+ }
+ }
+ }
+ const output = txStateHistoryHelper.snapshotFromTxMeta(input)
+ assert('foo' in output, 'has a foo key')
+ assert('bar' in output.foo, 'has a bar key')
+ assert('bam' in output.foo.bar, 'has a bar key')
+ assert.equal(output.foo.bar.bam, 'baz', 'has a baz value')
+ })
+
+ it('should remove the history key', function () {
+ const input = { foo: 'bar', history: 'remembered' }
+ const output = txStateHistoryHelper.snapshotFromTxMeta(input)
+ assert(typeof output.history, 'undefined', 'should remove history')
+ })
+})