diff options
author | Dan <danjm.com@gmail.com> | 2017-12-21 06:46:12 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2017-12-21 06:46:12 +0800 |
commit | 7915e62d65de1bbc3419cba58f69e6d55a4df3ea (patch) | |
tree | b1b9c006bac35381619eccde235d66e0a4c0bf1f /test/unit | |
parent | bccbf14b39ab2b1670c9c30b276404fe4f949cd7 (diff) | |
parent | d3f5ad874e4bf90cda4e440f9b0635c6ac416382 (diff) | |
download | tangerine-wallet-browser-7915e62d65de1bbc3419cba58f69e6d55a4df3ea.tar.gz tangerine-wallet-browser-7915e62d65de1bbc3419cba58f69e6d55a4df3ea.tar.zst tangerine-wallet-browser-7915e62d65de1bbc3419cba58f69e6d55a4df3ea.zip |
Merge branch 'master' into NewUI-flat
Diffstat (limited to 'test/unit')
-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') + }) + }) +}) + |