aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-07-27 08:04:57 +0800
committerEsteban MIno <efmino@uc.cl>2018-07-27 08:04:57 +0800
commitf79a249bcc65e594dcd058c30eab2620242ade9c (patch)
treeaf679b65fba7dd1e97a5c4062ef1c4e754cdf8f1
parent2827e13caab87692aa085af380355aeb42a13bdf (diff)
downloadtangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar.gz
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar.bz2
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar.lz
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar.xz
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.tar.zst
tangerine-wallet-browser-f79a249bcc65e594dcd058c30eab2620242ade9c.zip
modify tests according to tokens by network
-rw-r--r--test/unit/app/controllers/detect-tokens-test.js21
-rw-r--r--test/unit/app/controllers/preferences-controller-test.js5
2 files changed, 8 insertions, 18 deletions
diff --git a/test/unit/app/controllers/detect-tokens-test.js b/test/unit/app/controllers/detect-tokens-test.js
index 426ffe23a..d6c3fad8a 100644
--- a/test/unit/app/controllers/detect-tokens-test.js
+++ b/test/unit/app/controllers/detect-tokens-test.js
@@ -7,10 +7,11 @@ const PreferencesController = require('../../../../app/scripts/controllers/prefe
describe('DetectTokensController', () => {
const sandbox = sinon.createSandbox()
- let clock
- let keyringMemStore
- before(async () => {
+ let clock, keyringMemStore, network, preferences
+ beforeEach(async () => {
keyringMemStore = new ObservableStore({ isUnlocked: false})
+ network = new NetworkController({ provider: { type: 'mainnet' }})
+ preferences = new PreferencesController({ network })
})
after(() => {
sandbox.restore()
@@ -25,9 +26,7 @@ describe('DetectTokensController', () => {
it('should be called on every polling period', async () => {
clock = sandbox.useFakeTimers()
- const network = new NetworkController()
network.setProviderType('mainnet')
- const preferences = new PreferencesController()
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
controller.isUnlocked = true
@@ -45,9 +44,7 @@ describe('DetectTokensController', () => {
})
it('should not check tokens while in test network', async () => {
- const network = new NetworkController()
network.setProviderType('rinkeby')
- const preferences = new PreferencesController()
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
controller.isUnlocked = true
@@ -61,9 +58,7 @@ describe('DetectTokensController', () => {
})
it('should only check and add tokens while in main network', async () => {
- const network = new NetworkController()
network.setProviderType('mainnet')
- const preferences = new PreferencesController()
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
controller.isUnlocked = true
@@ -80,9 +75,7 @@ describe('DetectTokensController', () => {
})
it('should not detect same token while in main network', async () => {
- const network = new NetworkController()
network.setProviderType('mainnet')
- const preferences = new PreferencesController()
preferences.addToken('0x0d262e5dc4a06a0f1c90ce79c7a60c09dfc884e4', 'J8T', 8)
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
@@ -100,9 +93,7 @@ describe('DetectTokensController', () => {
})
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.isOpen = true
controller.isUnlocked = true
@@ -112,9 +103,7 @@ describe('DetectTokensController', () => {
})
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.isOpen = true
controller.selectedAddress = '0x0'
@@ -124,9 +113,7 @@ describe('DetectTokensController', () => {
})
it('should not trigger detect new tokens when not open or not unlocked', async () => {
- const network = new NetworkController()
network.setProviderType('mainnet')
- const preferences = new PreferencesController()
const controller = new DetectTokensController({ preferences: preferences, network: network, keyringMemStore: keyringMemStore })
controller.isOpen = true
controller.isUnlocked = false
diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js
index e055500b1..0b96fdfa5 100644
--- a/test/unit/app/controllers/preferences-controller-test.js
+++ b/test/unit/app/controllers/preferences-controller-test.js
@@ -1,11 +1,14 @@
const assert = require('assert')
+const ObservableStore = require('obs-store')
const PreferencesController = require('../../../../app/scripts/controllers/preferences')
describe('preferences controller', function () {
let preferencesController
+ let network
beforeEach(() => {
- preferencesController = new PreferencesController()
+ network = {providerStore: new ObservableStore({ type: 'mainnet' })}
+ preferencesController = new PreferencesController({ network })
})
describe('setAddresses', function () {