From c2cef0f815efb5667bf9aabff125cc1a8822283c Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Jan 2018 13:26:37 -0800 Subject: Set address to default with empty string, add test validation. --- test/unit/ui/add-token.spec.js | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/unit/ui/add-token.spec.js (limited to 'test/unit/ui') diff --git a/test/unit/ui/add-token.spec.js b/test/unit/ui/add-token.spec.js new file mode 100644 index 000000000..ee52f775f --- /dev/null +++ b/test/unit/ui/add-token.spec.js @@ -0,0 +1,44 @@ +const React = require('react') +const assert = require('assert') +const { createMockStore } = require('redux-test-utils') +const h = require('react-hyperscript') +const { shallowWithStore, mountWithStore } = require('../../lib/shallow-with-store') +const AddTokenScreen = require('../../../ui/app/add-token') + +describe.only('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.') + }) + + }) +}) -- cgit v1.2.3 From 0f10aa372982c0d072bfd8f3466d3a044f0a7e94 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Jan 2018 13:29:05 -0800 Subject: Clean up test, remove react & mountWithStore --- test/unit/ui/add-token.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/unit/ui') diff --git a/test/unit/ui/add-token.spec.js b/test/unit/ui/add-token.spec.js index ee52f775f..9e74aa37e 100644 --- a/test/unit/ui/add-token.spec.js +++ b/test/unit/ui/add-token.spec.js @@ -1,11 +1,10 @@ -const React = require('react') const assert = require('assert') const { createMockStore } = require('redux-test-utils') const h = require('react-hyperscript') -const { shallowWithStore, mountWithStore } = require('../../lib/shallow-with-store') +const { shallowWithStore } = require('../../lib/shallow-with-store') const AddTokenScreen = require('../../../ui/app/add-token') -describe.only('Add Token Screen', function () { +describe('Add Token Screen', function () { let addTokenComponent, store, component const mockState = { metamask: { -- cgit v1.2.3 From 6f14dc4702bf4d4593c4585f95d8b1ca3896043f Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 7 Feb 2018 19:50:11 -0330 Subject: Point add-token unit test to old-ui component. --- test/unit/ui/add-token.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/unit/ui') diff --git a/test/unit/ui/add-token.spec.js b/test/unit/ui/add-token.spec.js index 9e74aa37e..69b7fb620 100644 --- a/test/unit/ui/add-token.spec.js +++ b/test/unit/ui/add-token.spec.js @@ -2,7 +2,7 @@ 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('../../../ui/app/add-token') +const AddTokenScreen = require('../../../old-ui/app/add-token') describe('Add Token Screen', function () { let addTokenComponent, store, component -- cgit v1.2.3