diff options
author | Frankie <frankie.diamond@gmail.com> | 2017-12-22 03:37:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-22 03:37:37 +0800 |
commit | 9940ea71dfb2b1e478f134e7cd82fce0e134f071 (patch) | |
tree | f8494687303bd29c67a2090a30371a7bbb78a578 /test/unit | |
parent | cc7e85c078c0bd3ac69f4f2c2de07da8f4fb4d23 (diff) | |
parent | d3f5ad874e4bf90cda4e440f9b0635c6ac416382 (diff) | |
download | tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar.gz tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar.bz2 tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar.lz tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar.xz tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.tar.zst tangerine-wallet-browser-9940ea71dfb2b1e478f134e7cd82fce0e134f071.zip |
Merge branch 'master' into tx-param-vaalidation
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') + }) + }) +}) + |