Skip to content

Commit

Permalink
Fix some tests, Add badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Aguero committed Jan 15, 2019
1 parent b75e240 commit 93beb5b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import { withStyles } from '@material-ui/core/styles'
const AccountSummaryData = props => {
let statusMsg = getStatusMsg(props)
const tableData = [
{ title: 'Bonded amount', data: props.summary.bondedAmount },
{
title: 'Earned from delegate fees',
data: props.summary.fees
},
{
title: 'Status',
title: 'Bonding Status',
data: statusMsg
},
{
title: 'Stake',
data: props.summary.stake + ' LPT'
},
{
title: 'Earned from delegate fees',
data: props.summary.fees
}
]
const { classes } = props
Expand Down Expand Up @@ -68,7 +67,7 @@ const getStatusMsg = props => {
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your LPT is getting deluded by the protocol's token inflation.
Your LPT is getting deluded by the protocol's token inflation.
</p>
<p className={classes.textLeft}>
Add value to the network, bond to a transcoder
Expand Down Expand Up @@ -100,7 +99,7 @@ const getStatusMsg = props => {
<>
<p className={classes.textLeft}>{props.summary.status} </p>
<p className={classes.textLeft}>
bonded to transcoder <a href={delegateAddressUrl}>{delegateAddress}</a> at round{' '}
Bonded to transcoder <a href={delegateAddressUrl}>{delegateAddress}</a> at round{' '}
{props.summary.startRound}{' '}
</p>
{tokenRewardsText}
Expand All @@ -113,7 +112,7 @@ const getStatusMsg = props => {
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your still have to wait a few moments to get finally unbonded.
You still have to wait a few moments to get finally unbonded.
</p>
</>
)
Expand All @@ -124,7 +123,7 @@ const getStatusMsg = props => {
<>
<p className={classes.textLeft}>{props.summary.status}</p>
<p className={classes.textLeft}>
your LPT is getting deluded by the protocol's token inflation.
Your LPT is getting deluded by the protocol's token inflation.
</p>
<p className={classes.textLeft}>
Add value to the network, bond to a transcoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,20 @@ import { truncateStringInTheMiddle } from '../../../utils'
const AccountSummaryHome = props => {
let disabledBtn = props.summary && props.summary.status !== 'Bonded'
let subscriptionBtn
let isSubscribed = props.userData && props.userData.isSubscribed ? 'Yes' : 'No'

const { classes } = props
const tableData = [
{
title: 'Address',
data: props.userData.address
title: 'Wallet address',
data: truncateStringInTheMiddle(props.userData.address)
},
{
title: 'ETH Balance',
title: 'Wallet balance in ETH',
data: props.userData.ethBalance
},
{
title: 'LivePeer Balance',
title: 'Wallet balance in LPT',
data: props.lpBalance
},
{
title: 'Subscribed',
data: isSubscribed
}
]

Expand Down
19 changes: 19 additions & 0 deletions src/Components/Common/UI/Badge/Badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import PropTypes from 'prop-types'

// @material-ui/core components
import withStyles from '@material-ui/core/styles/withStyles'

import badgeStyle from '../../../../assets/jss/dashboard/components/badgeStyle.js'

function Badge({ ...props }) {
const { classes, color, children } = props
return <span className={classes.badge + ' ' + classes[color]}>{children}</span>
}

Badge.propTypes = {
classes: PropTypes.object.isRequired,
color: PropTypes.oneOf(['primary', 'warning', 'danger', 'success', 'info', 'rose', 'gray'])
}

export default withStyles(badgeStyle)(Badge)
46 changes: 20 additions & 26 deletions src/Tests/AccountSummary/AccountSummaryData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,21 @@ const props = {
}

describe('Renders account summary data', () => {
it('Shows bondedAmount', () => {
const message = 'Bonded amount'
let wrapper = mount(<AccountSummaryData {...props} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[1] === message).toEqual(true)
})
it('Shows Fees', () => {
const message = 'Earned from delegate fees'
let wrapper = mount(<AccountSummaryData {...props} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[3] === message).toEqual(true)
expect(tr[5] === message).toEqual(true)
})
it('Shows Status', () => {
const message = 'Status'
const message = 'Bonding Status'
let wrapper = mount(<AccountSummaryData {...props} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[5] === message).toEqual(true)
expect(tr[1] === message).toEqual(true)
})

it('Shows Bonded status msg if status is bonded and delegatedHasNotCalledReward', () => {
const messageStatus = 'bonded to transcoder 1234 at round 1'
const messageStatus = 'Bonded to transcoder 1234 at round 1'
const messageReward =
'Unfortunately the transcoder has not claimed the last inflationary token rewards.'
const propsStatus = {
Expand All @@ -54,11 +48,11 @@ describe('Renders account summary data', () => {
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageReward)).toEqual(true)
expect(tr[2].includes(messageStatus)).toEqual(true)
expect(tr[2].includes(messageReward)).toEqual(true)
})
it('Shows Bonded status msg if status is bonded and delegatedHasCalledReward', () => {
const messageStatus = 'bonded to transcoder 1234 at round 1'
const messageStatus = 'Bonded to transcoder 1234 at round 1'
const messageReward =
'The transcoder has successfully claimed the last inflationary token rewards.'
const propsStatus = {
Expand All @@ -71,12 +65,12 @@ describe('Renders account summary data', () => {
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageReward)).toEqual(true)
expect(tr[2].includes(messageStatus)).toEqual(true)
expect(tr[2].includes(messageReward)).toEqual(true)
})
it('Shows pending msg if status is pending', () => {
const messageStatus = 'Pending'
const messageExtra = "your LPT is getting deluded by the protocol's token inflation."
const messageExtra = "Your LPT is getting deluded by the protocol's token inflation."
const msgAddValue = 'Add value to the network, bond to a transcoder here'
const propsStatus = {
summary: {
Expand All @@ -85,13 +79,13 @@ describe('Renders account summary data', () => {
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
expect(tr[6].includes(msgAddValue)).toEqual(true)
expect(tr[2].includes(messageStatus)).toEqual(true)
expect(tr[2].includes(messageExtra)).toEqual(true)
expect(tr[2].includes(msgAddValue)).toEqual(true)
})
it('Shows Unbonded msg if status is Unbonded', () => {
const messageStatus = 'Unbonded'
const messageExtra = "your LPT is getting deluded by the protocol's token inflation."
const messageExtra = "Your LPT is getting deluded by the protocol's token inflation."
const msgAddValue = 'Add value to the network, bond to a transcoder here'
const propsStatus = {
summary: {
Expand All @@ -100,21 +94,21 @@ describe('Renders account summary data', () => {
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
expect(tr[6].includes(msgAddValue)).toEqual(true)
expect(tr[2].includes(messageStatus)).toEqual(true)
expect(tr[2].includes(messageExtra)).toEqual(true)
expect(tr[2].includes(msgAddValue)).toEqual(true)
})
it('Shows Unbonding msg if status is Unbonding', () => {
const messageStatus = 'Unbonding'
const messageExtra = 'your still have to wait a few moments to get finally unbonded.'
const messageExtra = 'You still have to wait a few moments to get finally unbonded.'
const propsStatus = {
summary: {
status: 'Unbonding'
}
}
let wrapper = mount(<AccountSummaryData {...propsStatus} />)
let tr = wrapper.find('TableCell').map(tr => tr.text())
expect(tr[6].includes(messageStatus)).toEqual(true)
expect(tr[6].includes(messageExtra)).toEqual(true)
expect(tr[2].includes(messageStatus)).toEqual(true)
expect(tr[2].includes(messageExtra)).toEqual(true)
})
})
6 changes: 3 additions & 3 deletions src/Tests/AccountSummary/AccountSummaryHome.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ describe('Renders userSubscribed data', () => {
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows address', () => {
const message = 'Address'
const message = 'Wallet address'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows ETH Balance', () => {
const message = 'ETH Balance'
const message = 'Wallet balance in ETH'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows Livepeer Balance', () => {
const message = 'LivePeer Balance'
const message = 'Wallet balance in LPT'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/Home/HomeCard/HomeCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ describe('Renders userSubscribed data', () => {
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows address', () => {
const message = 'Address'
const message = 'Wallet address'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows ETH Balance', () => {
const message = 'ETH Balance'
const message = 'Wallet balance in ETH'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
it('Shows Livepeer Balance', () => {
const message = 'LivePeer Balance'
const message = 'Wallet balance in LPT'
let wrapper = mount(<AccountSummaryHome {...props} />)
expect(wrapper.contains(message)).toEqual(true)
})
Expand Down

0 comments on commit 93beb5b

Please sign in to comment.