Mock notifier in test

feature/default_network_editable
Dan Finlay 7 years ago
parent f07ca73e07
commit ae156e1087
  1. 3
      app/scripts/controllers/preferences.js
  2. 5
      test/unit/app/controllers/metamask-controller-test.js

@ -35,6 +35,7 @@ class PreferencesController {
}, opts.initState) }, opts.initState)
this.getFirstTimeInfo = opts.getFirstTimeInfo || null this.getFirstTimeInfo = opts.getFirstTimeInfo || null
this.notifier = opts.notifier || notifier
this.store = new ObservableStore(initState) this.store = new ObservableStore(initState)
} }
@ -129,7 +130,7 @@ class PreferencesController {
// Notify our servers: // Notify our servers:
const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {}
notifier.notify(uri, { this.notifier.notify(uri, {
accounts: Object.keys(newlyLost), accounts: Object.keys(newlyLost),
metadata: { metadata: {
version, version,

@ -72,6 +72,11 @@ describe('MetaMaskController', function () {
it('removes any identities that do not correspond to known accounts.', async function () { it('removes any identities that do not correspond to known accounts.', async function () {
const fakeAddress = '0xbad0' const fakeAddress = '0xbad0'
metamaskController.preferencesController.addAddresses([fakeAddress]) metamaskController.preferencesController.addAddresses([fakeAddress])
metamaskController.preferencesController.notifier = {
notify: async () => {
return true
},
}
await metamaskController.submitPassword(password) await metamaskController.submitPassword(password)
const identities = Object.keys(metamaskController.preferencesController.store.getState().identities) const identities = Object.keys(metamaskController.preferencesController.store.getState().identities)

Loading…
Cancel
Save