diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/mock-store.js | 18 | ||||
-rw-r--r-- | test/unit/components/pending-tx-test.js | 29 |
2 files changed, 33 insertions, 14 deletions
diff --git a/test/lib/mock-store.js b/test/lib/mock-store.js new file mode 100644 index 000000000..4714c3485 --- /dev/null +++ b/test/lib/mock-store.js @@ -0,0 +1,18 @@ +const createStore = require('redux').createStore +const applyMiddleware = require('redux').applyMiddleware +const thunkMiddleware = require('redux-thunk') +const createLogger = require('redux-logger') +const rootReducer = function() {} + +module.exports = configureStore + +const loggerMiddleware = createLogger() + +const createStoreWithMiddleware = applyMiddleware( + thunkMiddleware, + loggerMiddleware +)(createStore) + +function configureStore (initialState) { + return createStoreWithMiddleware(rootReducer, initialState) +} diff --git a/test/unit/components/pending-tx-test.js b/test/unit/components/pending-tx-test.js index 2594a1a26..d7825d40e 100644 --- a/test/unit/components/pending-tx-test.js +++ b/test/unit/components/pending-tx-test.js @@ -1,11 +1,10 @@ const assert = require('assert') const additions = require('react-testutils-additions') const h = require('react-hyperscript') -var PendingTx = require('../../../ui/app/components/pending-tx') +const PendingTx = require('../../../ui/app/components/pending-tx') const createReactFactory = require('create-react-factory').createReactFactory const React = require('react') -console.dir(createReactFactory) -const shallow = require('enzyme').shallow +const shallow = require('react-test-renderer/shallow') const Factory = createReactFactory(PendingTx) const ReactTestUtils = require('react-addons-test-utils') @@ -53,23 +52,27 @@ describe.only('PendingTx', function () { } const pendingTxComponent = h(PendingTx, props) - var component = additions.renderIntoDocument(pendingTxComponent); + const component = additions.renderIntoDocument(pendingTxComponent); renderer.render(pendingTxComponent) const result = renderer.getRenderOutput() const form = result.props.children - console.log('FORM children') - console.dir(form.props.children) const children = form.props.children[form.props.children.length - 1] assert.equal(result.type, 'div', 'should create a div') - console.dir(children) - - console.log('finding input') try{ - const input = additions.find(component, '.cell.row input[type="number"]') - console.log('input') - console.dir(input) + const input = additions.find(component, '.cell.row input[type="number"]')[1] + ReactTestUtils.Simulate.change(input, { + target: { + value: 2, + checkValidity() { return true }, + } + }) + + let form = additions.find(component, 'form')[0] + form.checkValidity = () => true + form.getFormEl = () => { return { checkValidity() { return true } } } + ReactTestUtils.Simulate.submit(form, { preventDefault() {}, target: { checkValidity() {return true} } }) } catch (e) { console.log("WHAAAA") @@ -79,7 +82,6 @@ describe.only('PendingTx', function () { const noop = () => {} setTimeout(() => { - console.log('timeout finished') // Get the gas price input // Set it to the newGasPrice value @@ -91,7 +93,6 @@ describe.only('PendingTx', function () { }, 200) - console.log('calling render') }) }) |