aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:36:27 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-08-05 02:36:27 +0800
commit4ac0b972025ddd55a9a42b4a15db0a5f207f4078 (patch)
treefa0ddaf6fe3d47d355d925d87b6af3cff7d2a70c /test/unit
parentcaee2a9e35c0e80efed9da0798cb75044db6c920 (diff)
downloadtangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar.gz
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar.bz2
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar.lz
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar.xz
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.tar.zst
tangerine-wallet-browser-4ac0b972025ddd55a9a42b4a15db0a5f207f4078.zip
test for SufficientBalance
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/util-test.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/util-test.js b/test/unit/util-test.js
new file mode 100644
index 000000000..7716e4872
--- /dev/null
+++ b/test/unit/util-test.js
@@ -0,0 +1,41 @@
+const assert = require('assert')
+const { sufficientBalance } = require('../../app/scripts/lib/util')
+
+
+describe.only('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