1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/test/unit/nameForAccount_test.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

var assert = require('assert')
var sinon = require('sinon')
var path = require('path')
var contractNamer = require(path.join(__dirname, '..', '..', 'ui', 'lib', 'contract-namer.js'))
2017-05-04 23:35:10 +02:00
describe('contractNamer', function () {
beforeEach(function () {
this.sinon = sinon.sandbox.create()
})
2017-05-04 23:35:10 +02:00
afterEach(function () {
this.sinon.restore()
})
2017-05-04 23:35:10 +02:00
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)
})
2017-05-04 23:35:10 +02:00
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)
})
2017-05-04 23:35:10 +02:00
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)
})
})
})