Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Updated tests (lots of things have changed since this was originally …
Browse files Browse the repository at this point in the history
…committed)

(no more currency symbols, payment history button now always shows (but will have text saying when next contribution is)

Auditors: @bbondy, @mrose17
  • Loading branch information
bsclifton committed Jan 26, 2017
1 parent 80206d9 commit f078f46
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/renderer/components/preferences/paymentsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PaymentsTab extends ImmutableComponent {
let buttonText

if (!walletCreated) {
buttonText = null
return null
} else if (!walletHasTransactions) {
buttonText = 'noPaymentHistory'
} else {
Expand Down
33 changes: 24 additions & 9 deletions test/unit/app/renderer/paymentsTabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('PaymentsTab component', function () {
mockery.registerMock('../../less/forms.less', {})
mockery.registerMock('../../less/button.less', {})
mockery.registerMock('../../node_modules/font-awesome/css/font-awesome.css', {})
mockery.registerMock('../../extensions/brave/img/caret_down_grey.svg', 'caret_down_grey.svg')
mockery.registerMock('electron', fakeElectron)
mockery.registerMock('../../../../js/settings', fakeSettings)
fakeSettings.mockReturnValue = false
Expand All @@ -42,27 +43,41 @@ describe('PaymentsTab component', function () {

it('renders enabled content when enabled', function () {
fakeSettings.mockReturnValue = true
const wrapper = shallow(<PaymentsTab ledgerData={Immutable.Map()} />)
const wrapper = shallow(
<PaymentsTab
ledgerData={Immutable.Map()}
showOverlay={function () {}} />
)
assert.equal(wrapper.find('.disabledContent').length, 0)
assert.equal(wrapper.find('.walletBar').length, 1)
})
})

describe('rendering functions', function () {
it('renders a paymentsContainer', function () {
const wrapper = shallow(<PaymentsTab ledgerData={Immutable.Map()} />)
const wrapper = shallow(
<PaymentsTab
ledgerData={Immutable.Map()}
showOverlay={function () {}} />
)
assert(wrapper.find('.paymentsContainer'))
assert.equal(wrapper.find('.paymentsContainer').length, 1)
})

it('does not render any dialogs by default', function () {
const wrapper = shallow(<PaymentsTab ledgerData={Immutable.Map()} />)
const wrapper = shallow(
<PaymentsTab
ledgerData={Immutable.Map()}
showOverlay={function () {}} />
)
assert.equal(wrapper.find('.dialog').length, 0)
})

it('renders the create wallet button by default', function () {
const wrapper = shallow(
<PaymentsTab ledgerData={Immutable.Map()} />
<PaymentsTab
ledgerData={Immutable.Map()}
showOverlay={function () {}} />
)
assert.equal(wrapper.find('[data-test-id="createWallet"]').length, 1)
})
Expand All @@ -89,7 +104,7 @@ describe('PaymentsTab component', function () {
assert.equal(wrapper.find('[data-test-id="creatingWallet"]').length, 1)
})

it('renders payment history button when there are transactions', function () {
it('renders payment history button', function () {
const wrapper = shallow(
<PaymentsTab
showOverlay={function () {}}
Expand All @@ -99,12 +114,12 @@ describe('PaymentsTab component', function () {
assert.equal(wrapper.find('.paymentHistoryButton').length, 1)
})

it('does not render payment history button when there are no transactions', function () {
it('does not render payment history button when wallet is not created', function () {
const wrapper = shallow(
<PaymentsTab
showOverlay={function () {}}
hideOverlay={function () {}}
ledgerData={Immutable.Map({created: true, transactions: null})} />
ledgerData={Immutable.Map({created: false, balance: null})} />
)
assert.equal(wrapper.find('.paymentHistoryButton').length, 0)
})
Expand Down Expand Up @@ -154,7 +169,7 @@ describe('PaymentsTab component', function () {
ledgerData={Immutable.Map({created: false, btc: 10, amount: 10})} />
)
const inst = wrapper.instance()
assert.equal(inst.btcToCurrencyString(10), '$ 10.00')
assert.equal(inst.btcToCurrencyString(10), '10.00 USD')
})

it('renders partial balance correctly', function () {
Expand All @@ -166,7 +181,7 @@ describe('PaymentsTab component', function () {
ledgerData={Immutable.Map({created: false, btc: 10, amount: 2})} />
)
const inst = wrapper.instance()
assert.equal(inst.btcToCurrencyString(10), '$ 2.00')
assert.equal(inst.btcToCurrencyString(10), '2.00 USD')
})
})

Expand Down

0 comments on commit f078f46

Please sign in to comment.