diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2017-12-20 02:26:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-20 02:26:40 +0800 |
commit | 80b8098a27ed37e8644ef325d73e173cef033b96 (patch) | |
tree | 2035644bbc5a8f6342c06605eae48a1cf6665f13 /test | |
parent | 84dece92a6214b4ee562f69194c964a935e27af8 (diff) | |
parent | 8cc7e47369ab36c579a1996e0a119e1e27a8e8f2 (diff) | |
download | tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar.gz tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar.bz2 tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar.lz tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar.xz tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.tar.zst tangerine-wallet-browser-80b8098a27ed37e8644ef325d73e173cef033b96.zip |
Merge pull request #2771 from MetaMask/i2173-UpdateTokenValues
Allow updating token details
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/preferences-controller-test.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/preferences-controller-test.js b/test/unit/preferences-controller-test.js new file mode 100644 index 000000000..9fb5e4251 --- /dev/null +++ b/test/unit/preferences-controller-test.js @@ -0,0 +1,48 @@ +const assert = require('assert') +const PreferencesController = require('../../app/scripts/controllers/preferences') + +describe('preferences controller', function () { + let preferencesController + + before(() => { + preferencesController = new PreferencesController() + }) + + describe('addToken', function () { + it('should add that token to its state', async function () { + const address = '0xabcdef1234567' + const symbol = 'ABBR' + const decimals = 5 + + await preferencesController.addToken(address, symbol, decimals) + + const tokens = preferencesController.getTokens() + assert.equal(tokens.length, 1, 'one token added') + + const added = tokens[0] + assert.equal(added.address, address, 'set address correctly') + assert.equal(added.symbol, symbol, 'set symbol correctly') + assert.equal(added.decimals, decimals, 'set decimals correctly') + }) + + it('should allow updating a token value', async function () { + const address = '0xabcdef1234567' + const symbol = 'ABBR' + const decimals = 5 + + await preferencesController.addToken(address, symbol, decimals) + + const newDecimals = 6 + await preferencesController.addToken(address, symbol, newDecimals) + + const tokens = preferencesController.getTokens() + assert.equal(tokens.length, 1, 'one token added') + + const added = tokens[0] + assert.equal(added.address, address, 'set address correctly') + assert.equal(added.symbol, symbol, 'set symbol correctly') + assert.equal(added.decimals, newDecimals, 'updated decimals correctly') + }) + }) +}) + |