From d60991ec88fe88be4041eb4a9392df6dfc1aa973 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Mon, 10 Sep 2018 17:01:15 -0700 Subject: Delete ConfigManager, replacing its usages with PreferencesController --- .../app/controllers/metamask-controller-test.js | 34 ++++++++++------------ .../unit/app/controllers/notice-controller-test.js | 7 +---- .../app/controllers/preferences-controller-test.js | 30 +++++++++++++++++++ 3 files changed, 46 insertions(+), 25 deletions(-) (limited to 'test/unit/app/controllers') diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index 85c78fe1e..e7a28bedb 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -584,22 +584,18 @@ describe('MetaMaskController', function () { }) describe('#clearSeedWordCache', function () { + it('should set seed words to null', function (done) { + sandbox.stub(metamaskController.preferencesController, 'setSeedWords') + metamaskController.clearSeedWordCache((err) => { + if (err) { + done(err) + } - it('should have set seed words', function () { - metamaskController.configManager.setSeedWords('test words') - const getConfigSeed = metamaskController.configManager.getSeedWords() - assert.equal(getConfigSeed, 'test words') - }) - - it('should clear config seed phrase', function () { - metamaskController.configManager.setSeedWords('test words') - metamaskController.clearSeedWordCache((err, result) => { - if (err) console.log(err) + assert.ok(metamaskController.preferencesController.setSeedWords.calledOnce) + assert.deepEqual(metamaskController.preferencesController.setSeedWords.args, [[null]]) + done() }) - const getConfigSeed = metamaskController.configManager.getSeedWords() - assert.equal(getConfigSeed, null) }) - }) describe('#setCurrentLocale', function () { @@ -793,24 +789,24 @@ describe('MetaMaskController', function () { describe('#markAccountsFound', function () { it('adds lost accounts to config manager data', function () { metamaskController.markAccountsFound(noop) - const configManagerData = metamaskController.configManager.getData() - assert.deepEqual(configManagerData.lostAccounts, []) + const state = metamaskController.getState() + assert.deepEqual(state.lostAccounts, []) }) }) describe('#markPasswordForgotten', function () { it('adds and sets forgottenPassword to config data to true', function () { metamaskController.markPasswordForgotten(noop) - const configManagerData = metamaskController.configManager.getData() - assert.equal(configManagerData.forgottenPassword, true) + const state = metamaskController.getState() + assert.equal(state.forgottenPassword, true) }) }) describe('#unMarkPasswordForgotten', function () { it('adds and sets forgottenPassword to config data to false', function () { metamaskController.unMarkPasswordForgotten(noop) - const configManagerData = metamaskController.configManager.getData() - assert.equal(configManagerData.forgottenPassword, false) + const state = metamaskController.getState() + assert.equal(state.forgottenPassword, false) }) }) diff --git a/test/unit/app/controllers/notice-controller-test.js b/test/unit/app/controllers/notice-controller-test.js index b3ae75080..5e6ae9ac5 100644 --- a/test/unit/app/controllers/notice-controller-test.js +++ b/test/unit/app/controllers/notice-controller-test.js @@ -1,16 +1,11 @@ const assert = require('assert') -const configManagerGen = require('../../../lib/mock-config-manager') const NoticeController = require('../../../../app/scripts/notice-controller') describe('notice-controller', function () { var noticeController beforeEach(function () { - // simple localStorage polyfill - const configManager = configManagerGen() - noticeController = new NoticeController({ - configManager: configManager, - }) + noticeController = new NoticeController({}) }) describe('notices', function () { diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 2c261be90..b5ccf3fb5 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -449,5 +449,35 @@ describe('preferences controller', function () { assert.ok(assetImages[address], `set image correctly`) }) }) + + describe('setPasswordForgotten', function () { + it('should default to false', function () { + const state = preferencesController.store.getState() + assert.equal(state.forgottenPassword, false) + }) + + it('should set the forgottenPassword property in state', function () { + assert.equal(preferencesController.store.getState().forgottenPassword, false) + + preferencesController.setPasswordForgotten(true) + + assert.equal(preferencesController.store.getState().forgottenPassword, true) + }) + }) + + describe('setSeedWords', function () { + it('should default to null', function () { + const state = preferencesController.store.getState() + assert.equal(state.seedWords, null) + }) + + it('should set the seedWords property in state', function () { + assert.equal(preferencesController.store.getState().seedWords, null) + + preferencesController.setSeedWords('foo bar baz') + + assert.equal(preferencesController.store.getState().seedWords, 'foo bar baz') + }) + }) }) -- cgit