aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/nameForAccount_test.js44
-rw-r--r--test/unit/util_test.js6
2 files changed, 50 insertions, 0 deletions
diff --git a/test/unit/nameForAccount_test.js b/test/unit/nameForAccount_test.js
new file mode 100644
index 000000000..6839d40f8
--- /dev/null
+++ b/test/unit/nameForAccount_test.js
@@ -0,0 +1,44 @@
+var assert = require('assert')
+var sinon = require('sinon')
+
+var path = require('path')
+var contractNamer = require(path.join(__dirname, '..', '..', 'ui', 'lib', 'contract-namer.js'))
+
+describe('contractNamer', function() {
+
+ beforeEach(function() {
+ this.sinon = sinon.sandbox.create()
+ })
+
+ afterEach(function() {
+ this.sinon.restore()
+ })
+
+ describe('naming a contract', function() {
+
+ it('should return nothing for an unknown random account', function() {
+ const input = '0x2386F26FC10000'
+ const output = contractNamer(input)
+ assert.deepEqual(output, null)
+ })
+
+ it('should accept identities as an optional second parameter', function() {
+ const input = '0x2386F26FC10000'.toLowerCase()
+ const expected = 'bar'
+ const identities = {}
+ identities[input] = { name: expected }
+ const output = contractNamer(input, identities)
+ assert.deepEqual(output, expected)
+ })
+
+ it('should check for identities case insensitively', function() {
+ const input = '0x2386F26FC10000'.toLowerCase()
+ const expected = 'bar'
+ const identities = {}
+ identities[input] = { name: expected }
+ const output = contractNamer(input.toUpperCase(), identities)
+ assert.deepEqual(output, expected)
+ })
+
+ })
+})
diff --git a/test/unit/util_test.js b/test/unit/util_test.js
index e2390c8d4..28f76fcf1 100644
--- a/test/unit/util_test.js
+++ b/test/unit/util_test.js
@@ -52,6 +52,12 @@ describe('util', function() {
var result = util.addressSummary(address)
assert.equal(result, '0xFDEa65C8...b825')
})
+
+ it('should accept arguments for firstseg, lastseg, and keepPrefix', function() {
+ var address = '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825'
+ var result = util.addressSummary(address, 4, 4, false)
+ assert.equal(result, 'FDEa...b825')
+ })
})
describe('isValidAddress', function() {