Merge pull request #3206 from danjm/merge-uat-to-uatnext-feb072019
[NewUI] Merge uat to uatnext feb072019feature/default_network_editable
commit
f39222c9af
@ -0,0 +1,34 @@ |
||||
const version = 21 |
||||
|
||||
/* |
||||
|
||||
This migration removes the BlackListController from disk state |
||||
|
||||
*/ |
||||
|
||||
const clone = require('clone') |
||||
|
||||
module.exports = { |
||||
version, |
||||
|
||||
migrate: function (originalVersionedData) { |
||||
const versionedData = clone(originalVersionedData) |
||||
versionedData.meta.version = version |
||||
try { |
||||
const state = versionedData.data |
||||
const newState = transformState(state) |
||||
versionedData.data = newState |
||||
} catch (err) { |
||||
console.warn(`MetaMask Migration #${version}` + err.stack) |
||||
} |
||||
return Promise.resolve(versionedData) |
||||
}, |
||||
} |
||||
|
||||
function transformState (state) { |
||||
const newState = state |
||||
delete newState.BlacklistController |
||||
delete newState.RecentBlocks |
||||
return newState |
||||
} |
||||
|
File diff suppressed because one or more lines are too long
@ -1,16 +1,20 @@ |
||||
const { shallow, mount } = require('enzyme') |
||||
|
||||
exports.shallowWithStore = function shallowWithStore (component, store) { |
||||
module.exports = { |
||||
shallowWithStore, |
||||
mountWithStore, |
||||
} |
||||
|
||||
function shallowWithStore (component, store) { |
||||
const context = { |
||||
store, |
||||
} |
||||
|
||||
return shallow(component, { context }) |
||||
return shallow(component, {context}) |
||||
} |
||||
|
||||
exports.mountWithStore = function mountWithStore (component, store) { |
||||
function mountWithStore (component, store) { |
||||
const context = { |
||||
store, |
||||
} |
||||
return mount(component, { context }) |
||||
return mount(component, {context}) |
||||
} |
||||
|
@ -0,0 +1,16 @@ |
||||
const assert = require('assert') |
||||
|
||||
const wallet2 = require('../../lib/migrations/002.json') |
||||
const migration21 = require('../../../app/scripts/migrations/021') |
||||
|
||||
describe('wallet2 is migrated successfully with out the BlacklistController', () => { |
||||
it('should delete BlacklistController key', (done) => { |
||||
migration21.migrate(wallet2) |
||||
.then((migratedData) => { |
||||
assert.equal(migratedData.meta.version, 21) |
||||
assert(!migratedData.data.BlacklistController) |
||||
assert(!migratedData.data.RecentBlocks) |
||||
done() |
||||
}).catch(done) |
||||
}) |
||||
}) |
@ -0,0 +1,43 @@ |
||||
const assert = require('assert') |
||||
const { createMockStore } = require('redux-test-utils') |
||||
const h = require('react-hyperscript') |
||||
const { shallowWithStore } = require('../../lib/shallow-with-store') |
||||
const AddTokenScreen = require('../../../old-ui/app/add-token') |
||||
|
||||
describe('Add Token Screen', function () { |
||||
let addTokenComponent, store, component |
||||
const mockState = { |
||||
metamask: { |
||||
identities: { |
||||
'0x7d3517b0d011698406d6e0aed8453f0be2697926': { |
||||
'address': '0x7d3517b0d011698406d6e0aed8453f0be2697926', |
||||
'name': 'Add Token Name', |
||||
}, |
||||
}, |
||||
}, |
||||
} |
||||
beforeEach(function () { |
||||
store = createMockStore(mockState) |
||||
component = shallowWithStore(h(AddTokenScreen), store) |
||||
addTokenComponent = component.dive() |
||||
}) |
||||
|
||||
describe('#ValidateInputs', function () { |
||||
|
||||
it('Default State', function () { |
||||
addTokenComponent.instance().validateInputs() |
||||
const state = addTokenComponent.state() |
||||
assert.equal(state.warning, 'Address is invalid.') |
||||
}) |
||||
|
||||
it('Address is a Metamask Identity', function () { |
||||
addTokenComponent.setState({ |
||||
address: '0x7d3517b0d011698406d6e0aed8453f0be2697926', |
||||
}) |
||||
addTokenComponent.instance().validateInputs() |
||||
const state = addTokenComponent.state() |
||||
assert.equal(state.warning, 'Personal address detected. Input the token contract address.') |
||||
}) |
||||
|
||||
}) |
||||
}) |
Loading…
Reference in new issue