aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js
diff options
context:
space:
mode:
authorThomas <thomas.b.huang@gmail.com>2018-07-26 13:38:44 +0800
committerThomas <thomas.b.huang@gmail.com>2018-07-26 13:38:44 +0800
commit138858647ed28a8aaba4b7e18e387ea0b6af0889 (patch)
tree0bc936ee7316112d01e617a246a645e3914da949 /ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js
parentfa02a6c7c65f6866998171881fd657570fe3fe7b (diff)
parenta5d344a58223e029dc86bf33a8ca9357492765f3 (diff)
downloadtangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar.gz
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar.bz2
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar.lz
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar.xz
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.tar.zst
tangerine-wallet-browser-138858647ed28a8aaba4b7e18e387ea0b6af0889.zip
Merge branch 'develop' into network-remove-provider-engine
Diffstat (limited to 'ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js')
-rw-r--r--ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js
new file mode 100644
index 000000000..4d2447c32
--- /dev/null
+++ b/ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js
@@ -0,0 +1,51 @@
+import assert from 'assert'
+import proxyquire from 'proxyquire'
+import sinon from 'sinon'
+
+import {
+ REQUIRED_ERROR,
+ INVALID_RECIPIENT_ADDRESS_ERROR,
+} from '../../../send.constants'
+
+const stubs = {
+ isValidAddress: sinon.stub().callsFake(to => Boolean(to.match(/^[0xabcdef123456798]+$/))),
+}
+
+const toRowUtils = proxyquire('../send-to-row.utils.js', {
+ '../../../../util': {
+ isValidAddress: stubs.isValidAddress,
+ },
+})
+const {
+ getToErrorObject,
+} = toRowUtils
+
+describe('send-to-row utils', () => {
+
+ describe('getToErrorObject()', () => {
+ it('should return a required error if to is falsy', () => {
+ assert.deepEqual(getToErrorObject(null), {
+ to: REQUIRED_ERROR,
+ })
+ })
+
+ it('should return an invalid recipient error if to is truthy but invalid', () => {
+ assert.deepEqual(getToErrorObject('mockInvalidTo'), {
+ to: INVALID_RECIPIENT_ADDRESS_ERROR,
+ })
+ })
+
+ it('should return null if to is truthy and valid', () => {
+ assert.deepEqual(getToErrorObject('0xabc123'), {
+ to: null,
+ })
+ })
+
+ it('should return the passed error if to is truthy but invalid if to is truthy and valid', () => {
+ assert.deepEqual(getToErrorObject('invalid #$ 345878', 'someExplicitError'), {
+ to: 'someExplicitError',
+ })
+ })
+ })
+
+})