mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
d5c378b09a
Fixes #197 Also as a side effect, by creating this `iconFactory.cache` object, we have a convenient place for specifying stock icons for known contracts! We can just hard-code image addresses in the `ui/lib/icon-factory.js` cache instantiation, and those values will be injected into the identicon image tag `src` attributes.
32 lines
993 B
JavaScript
32 lines
993 B
JavaScript
const assert = require('assert')
|
|
const sinon = require('sinon')
|
|
|
|
const path = require('path')
|
|
const IconFactoryGen = require(path.join(__dirname, '..', '..', '..', 'ui', 'lib', 'icon-factory.js'))
|
|
|
|
describe('icon-factory', function() {
|
|
let iconFactory, address, diameter
|
|
|
|
beforeEach(function() {
|
|
iconFactory = IconFactoryGen((d,n) => 'stubicon')
|
|
address = '0x012345671234567890'
|
|
diameter = 50
|
|
})
|
|
|
|
it('should return a data-uri string for any address and diameter', function() {
|
|
const output = iconFactory.iconForAddress(address, diameter)
|
|
assert.ok(output.indexOf('data:image/svg') === 0)
|
|
assert.equal(output, iconFactory.cache[address][diameter])
|
|
})
|
|
|
|
it('should default to cache first', function() {
|
|
const testOutput = 'foo'
|
|
const mockSizeCache = {}
|
|
mockSizeCache[diameter] = testOutput
|
|
iconFactory.cache[address] = mockSizeCache
|
|
|
|
const output = iconFactory.iconForAddress(address, diameter)
|
|
assert.equal(output, testOutput)
|
|
})
|
|
})
|