aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/nameForAccount_test.js
blob: 32af49e9d650bab22c1117d38d385ad8833aec94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var assert = require('assert')
var sinon = require('sinon')

var path = require('path')
var contractNamer = require(path.join(__dirname, '..', '..', 'old-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)
    })
  })
})