aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-03-17 01:21:21 +0800
committerGitHub <noreply@github.com>2017-03-17 01:21:21 +0800
commit00f1a2d78d01301f51157e9c8b8352dc0796d034 (patch)
tree91d9cbb8baa26efa462a86e9ecda460792f90996 /test/unit
parent570cc891b5386dc04462737de4df6f2adf5059c9 (diff)
parenta186e40d179d230fc1e81f7f507a5232d23ad462 (diff)
downloadtangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.gz
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.bz2
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.lz
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.xz
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.zst
tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.zip
Merge pull request #1198 from MetaMask/i1165-predictive
Add predictive address functionality to recipient field in send
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/address-book-controller.js56
-rw-r--r--test/unit/currency-controller-test.js2
2 files changed, 57 insertions, 1 deletions
diff --git a/test/unit/address-book-controller.js b/test/unit/address-book-controller.js
new file mode 100644
index 000000000..f345b0328
--- /dev/null
+++ b/test/unit/address-book-controller.js
@@ -0,0 +1,56 @@
+const assert = require('assert')
+const extend = require('xtend')
+const AddressBookController = require('../../app/scripts/controllers/address-book')
+
+const mockKeyringController = {
+ memStore: {
+ getState: function () {
+ return {
+ identities: {
+ '0x0aaa' : {
+ address: '0x0aaa',
+ name: 'owned',
+ }
+ }
+ }
+ }
+ }
+}
+
+
+describe('address-book-controller', function() {
+ var addressBookController
+
+ beforeEach(function() {
+ addressBookController = new AddressBookController({}, mockKeyringController)
+ })
+
+ 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.')
+ })
+ })
+ })
+})
diff --git a/test/unit/currency-controller-test.js b/test/unit/currency-controller-test.js
index dd7fa91e0..079f8b488 100644
--- a/test/unit/currency-controller-test.js
+++ b/test/unit/currency-controller-test.js
@@ -7,7 +7,7 @@ const rp = require('request-promise')
const nock = require('nock')
const CurrencyController = require('../../app/scripts/controllers/currency')
-describe('config-manager', function() {
+describe('currency-controller', function() {
var currencyController
beforeEach(function() {