From 9140892c02b1758a9c8d8b96db1fbac37d58fc4f Mon Sep 17 00:00:00 2001 From: reyraa Date: Tue, 8 Aug 2017 17:04:44 +0200 Subject: [PATCH 1/5] - Create priced button. - Add unit test coverage. - Add fees to constants --- src/components/pricedButton/index.js | 28 ++++++++++ src/components/pricedButton/index.test.js | 56 ++++++++++++++++++++ src/components/pricedButton/pricedButton.css | 11 ++++ src/constants/fees.js | 5 ++ 4 files changed, 100 insertions(+) create mode 100644 src/components/pricedButton/index.js create mode 100644 src/components/pricedButton/index.test.js create mode 100644 src/components/pricedButton/pricedButton.css create mode 100644 src/constants/fees.js diff --git a/src/components/pricedButton/index.js b/src/components/pricedButton/index.js new file mode 100644 index 000000000..7bbcd9ad0 --- /dev/null +++ b/src/components/pricedButton/index.js @@ -0,0 +1,28 @@ +import React from 'react'; +import Button from 'react-toolbox/lib/button'; +import { fromRawLsk } from '../../utils/lsk'; +import styles from './pricedButton.css'; + +const PricedButton = (props) => { + const hasFunds = props.balance >= props.fee; + return ( +
+ { + props.fee && + + { + hasFunds ? `Fee: ${fromRawLsk(props.fee)} LSK` : + `Not enough credit to pay ${fromRawLsk(props.fee)} LSK fee` + } + + } +
+ ); +}; + +export default PricedButton; diff --git a/src/components/pricedButton/index.test.js b/src/components/pricedButton/index.test.js new file mode 100644 index 000000000..990db0229 --- /dev/null +++ b/src/components/pricedButton/index.test.js @@ -0,0 +1,56 @@ +import React from 'react'; +import chai, { expect } from 'chai'; +import sinonChai from 'sinon-chai'; +import sinon from 'sinon'; +import { shallow } from 'enzyme'; +import chaiEnzyme from 'chai-enzyme'; +import Button from 'react-toolbox/lib/button'; +import PricedButton from './index'; + +chai.use(sinonChai); +chai.use(chaiEnzyme()); + +describe.only('DialogElement', () => { + let wrapper; + const props = { + fee: 5e8, + onClick: sinon.spy(), + }; + const insufficientBalance = 0; + const sufficientBalance = 6e8; + + it('renders