A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/test/unit/app/controllers/address-book-controller.js

55 lines
1.9 KiB

8 years ago
const assert = require('assert')
const AddressBookController = require('../../../../app/scripts/controllers/address-book')
8 years ago
const stubPreferencesStore = {
getState: function () {
return {
identities: {
'0x0aaa': {
address: '0x0aaa',
name: 'owned',
8 years ago
},
},
}
8 years ago
},
7 years ago
}
8 years ago
describe('address-book-controller', function () {
8 years ago
var addressBookController
8 years ago
beforeEach(function () {
addressBookController = new AddressBookController({
preferencesStore: stubPreferencesStore,
})
8 years ago
})
describe('addres book management', function () {
describe('#_getAddressBook', function () {
it('should be empty by default.', function () {
assert.equal(addressBookController._getAddressBook().length, 0)
})
})
describe('#setAddressBook', function () {
it('should properly set a new address.', function () {
addressBookController.setAddressBook('0x01234', 'test')
var addressBook = addressBookController._getAddressBook()
assert.equal(addressBook.length, 1, 'incorrect address book length.')
assert.equal(addressBook[0].address, '0x01234', 'incorrect addresss')
assert.equal(addressBook[0].name, 'test', 'incorrect nickname')
})
it('should reject duplicates.', function () {
addressBookController.setAddressBook('0x01234', 'test')
addressBookController.setAddressBook('0x01234', 'test')
var addressBook = addressBookController._getAddressBook()
assert.equal(addressBook.length, 1, 'incorrect address book length.')
})
it('should not add any identities that are under user control', function () {
addressBookController.setAddressBook('0x0aaa', ' ')
var addressBook = addressBookController._getAddressBook()
assert.equal(addressBook.length, 0, 'incorrect address book length.')
})
8 years ago
})
})
})