aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-07-20 07:46:46 +0800
committerEsteban MIno <efmino@uc.cl>2018-07-20 07:46:46 +0800
commit009b1cefbe3d19dcad01078927b1a55c3439b22f (patch)
tree1c2e85df7fe5086c95c0b98c3fb3029c31ddf0d1 /test
parent3b97d816ffcaebc7606d4564ea95918f647ba413 (diff)
downloadtangerine-wallet-browser-009b1cefbe3d19dcad01078927b1a55c3439b22f.tar.gz
tangerine-wallet-browser-009b1cefbe3d19dcad01078927b1a55c3439b22f.tar.zst
tangerine-wallet-browser-009b1cefbe3d19dcad01078927b1a55c3439b22f.zip
keyring unlocked detect and unit tests
Diffstat (limited to 'test')
-rw-r--r--test/unit/app/controllers/detect-tokens-test.js38
1 files changed, 32 insertions, 6 deletions
diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js
index 49492c543..dcb3c431f 100644
--- a/test/unit/app/controllers/detect-tokens-test.js
+++ b/test/unit/app/controllers/detect-tokens-test.js
@@ -1,14 +1,17 @@
const assert = require('assert')
const sinon = require('sinon')
+const ObservableStore = require('obs-store')
const DetectTokensController = require('../../../../app/scripts/controllers/detect-tokens')
const NetworkController = require('../../../../app/scripts/controllers/network/network')
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
describe('DetectTokensController', () => {
- const sandbox = sinon.createSandbox()
+ const sandbox = sinon.createSandbox()
let clock
+ let keyringMemStore
before(async () => {
- })
+ keyringMemStore = new ObservableStore({ isUnlocked: false})
+ })
after(() => {
sandbox.restore()
})
@@ -25,7 +28,7 @@ describe('DetectTokensController', () => {
const network = new NetworkController()
network.setProviderType('mainnet')
const preferences = new PreferencesController()
- const controller = new DetectTokensController({preferences: preferences, network: network})
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isActive = true
var stub = sandbox.stub(controller, 'detectNewTokens')
@@ -44,7 +47,7 @@ describe('DetectTokensController', () => {
const network = new NetworkController()
network.setProviderType('rinkeby')
const preferences = new PreferencesController()
- const controller = new DetectTokensController({preferences: preferences, network: network})
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isActive = true
var stub = sandbox.stub(controller, 'detectTokenBalance')
@@ -59,7 +62,7 @@ describe('DetectTokensController', () => {
const network = new NetworkController()
network.setProviderType('mainnet')
const preferences = new PreferencesController()
- const controller = new DetectTokensController({preferences: preferences, network: network})
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isActive = true
sandbox.stub(controller, 'detectTokenBalance')
@@ -78,7 +81,7 @@ describe('DetectTokensController', () => {
network.setProviderType('mainnet')
const preferences = new PreferencesController()
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
- const controller = new DetectTokensController({preferences: preferences, network: network})
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isActive = true
sandbox.stub(controller, 'detectTokenBalance')
@@ -91,4 +94,27 @@ describe('DetectTokensController', () => {
assert.deepEqual(preferences.store.getState().tokens, [{address: '0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', decimals: 8, symbol: 'J8T'},
{address: '0xbc86727e770de68b1060c91f6bb6945c73e10388', decimals: 18, symbol: 'XNK'}])
})
+
+ it('should trigger detect new tokens when change address', async () => {
+ const network = new NetworkController()
+ network.setProviderType('mainnet')
+ const preferences = new PreferencesController()
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
+ controller.isActive = true
+ var stub = sandbox.stub(controller, 'detectNewTokens')
+ await preferences.setSelectedAddress('0xbc86727e770de68b1060c91f6bb6945c73e10388')
+ sandbox.assert.called(stub)
+ })
+
+ it('should trigger detect new tokens when submit password', async () => {
+ const network = new NetworkController()
+ network.setProviderType('mainnet')
+ const preferences = new PreferencesController()
+ const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
+ controller.isActive = true
+ controller.selectedAddress = '0x0'
+ var stub = sandbox.stub(controller, 'detectNewTokens')
+ await controller._keyringMemStore.updateState({ isUnlocked: true })
+ sandbox.assert.called(stub)
+ })
})