Skip to content

Commit

Permalink
add some basic tests for the coin selection modal component
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Jun 23, 2023
1 parent 7c7f37c commit 177c874
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/components/CoinSelectionModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,62 @@ describe('Basic styling test of the CoinSelectionModal component', () => {
const modal = screen.getByTestId('testCoinSelectionModal')
expect(modal.props.children.props.children.props.style[0].paddingHorizontal).toBe(0)
})
it('hides the confirm button if not enough proofs are selected', () => {
render(
<CoinSelectionModal
lnAmount={10}
disableCS={() => l('test coin selection modal')}
proofs={[
{ selected: false, amount: 4, secret: '', C: '', id: '0' },
{ selected: false, amount: 8, secret: '', C: '', id: '1' },
]}
setProof={() => l('proofs')}
/>
)
expect(screen.queryByText('Confirm')).toBeNull()
})
it('should display the confirm button if enough proofs are selected', () => {
render(
<CoinSelectionModal
lnAmount={10}
disableCS={() => l('test coin selection modal')}
proofs={[
{ selected: true, amount: 4, secret: '', C: '', id: '0' },
{ selected: true, amount: 8, secret: '', C: '', id: '1' },
]}
setProof={() => l('proofs')}
/>
)
expect(screen.getByText('Confirm')).toBeDefined()
})
it('should display the change after selecting more proofs than needed', () => {
render(
<CoinSelectionModal
lnAmount={10}
disableCS={() => l('test coin selection modal')}
proofs={[
{ selected: true, amount: 4, secret: '', C: '', id: '0' },
{ selected: true, amount: 8, secret: '', C: '', id: '1' },
]}
setProof={() => l('proofs')}
/>
)
expect(screen.getByText('Change')).toBeDefined()
expect(screen.getByText('2 Sat')).toBeDefined()
})
it('should not display the change after selecting the exact proofs needed', () => {
render(
<CoinSelectionModal
lnAmount={10}
disableCS={() => l('test coin selection modal')}
proofs={[
{ selected: true, amount: 4, secret: '', C: '', id: '0' },
{ selected: true, amount: 4, secret: '', C: '', id: '1' },
{ selected: true, amount: 2, secret: '', C: '', id: '2' },
]}
setProof={() => l('proofs')}
/>
)
expect(screen.queryByText('Change')).toBeNull()
})
})

0 comments on commit 177c874

Please sign in to comment.