aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/app/util-test.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-05-24 02:33:15 +0800
committerDan <danjm.com@gmail.com>2018-05-24 02:33:15 +0800
commit440905125d77d1d5d72d1aceac2940925a8ac38f (patch)
treed5418384983f9de8092d2dfdd1ddddec2ffd555e /test/unit/app/util-test.js
parent3dec7cb52443b24d6a24f75434ee41a54f4cfd0b (diff)
parented01c6c8264a860cdc4248991839954bdf22e2ef (diff)
downloadtangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar.gz
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar.bz2
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar.lz
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar.xz
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.tar.zst
tangerine-wallet-browser-440905125d77d1d5d72d1aceac2940925a8ac38f.zip
Merge branch 'develop' into i3725-refactor-send-component-
Diffstat (limited to 'test/unit/app/util-test.js')
-rw-r--r--test/unit/app/util-test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/app/util-test.js b/test/unit/app/util-test.js
new file mode 100644
index 000000000..670bc4d22
--- /dev/null
+++ b/test/unit/app/util-test.js
@@ -0,0 +1,41 @@
+const assert = require('assert')
+const { sufficientBalance } = require('../../../app/scripts/lib/util')
+
+
+describe('SufficientBalance', function () {
+ it('returns true if max tx cost is equal to balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x8'
+
+ const result = sufficientBalance(tx, balance)
+ assert.ok(result, 'sufficient balance found.')
+ })
+
+ it('returns true if max tx cost is less than balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x9'
+
+ const result = sufficientBalance(tx, balance)
+ assert.ok(result, 'sufficient balance found.')
+ })
+
+ it('returns false if max tx cost is more than balance.', function () {
+ const tx = {
+ 'value': '0x1',
+ 'gas': '0x2',
+ 'gasPrice': '0x3',
+ }
+ const balance = '0x6'
+
+ const result = sufficientBalance(tx, balance)
+ assert.ok(!result, 'insufficient balance found.')
+ })
+}) \ No newline at end of file