aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-12-19 07:49:55 +0800
committerDan Finlay <dan@danfinlay.com>2017-12-19 07:56:50 +0800
commit9bb701f0633bb117bf67f13935b5e121b6b9837a (patch)
tree12d45edfe23398d801b43a7ce7510cc7955568c0 /test
parent84dece92a6214b4ee562f69194c964a935e27af8 (diff)
downloadtangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar.gz
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar.bz2
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar.lz
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar.xz
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.tar.zst
tangerine-wallet-browser-9bb701f0633bb117bf67f13935b5e121b6b9837a.zip
Add failing test for updating token details
Diffstat (limited to 'test')
-rw-r--r--test/unit/preferences-controller-test.js48
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')
+ })
+ })
+})
+