Skip to content

Commit 13b4098

Browse files
committed
Add tests for the address page
1 parent 987eaed commit 13b4098

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
describe('address page', function() {
2+
before(() => {
3+
// Prepare an address for testing
4+
cy.task('bitcoind:newaddr').as('test_addr').then(test_addr => {
5+
cy.task('bitcoind:sendto', { addr: test_addr, amount: 0.1 }).as('test_txid1')
6+
cy.task('bitcoind:sendto', { addr: test_addr, amount: 0.2 }).as('test_txid2')
7+
cy.task('bitcoind:mine')
8+
cy.task('bitcoind:sendto', { addr: test_addr, amount: 0.4 }).as('test_txid3')
9+
cy.wait(6000)
10+
cy.visit(`/address/${test_addr}`)
11+
})
12+
})
13+
14+
it('displays the address stats', function() {
15+
cy.get('.stats-table')
16+
.contains('> div', 'Confirmed received')
17+
.find('div:eq(1)')
18+
.should('have.text', '2 outputs (0.3 rBTC)')
19+
20+
cy.get('.stats-table')
21+
.contains('> div', 'Unconfirmed received')
22+
.find('div:eq(1)')
23+
.should('have.text', '1 output (0.4 rBTC)')
24+
25+
cy.get('.stats-table')
26+
.contains('> div', 'Total unspent')
27+
.find('div:eq(1)')
28+
.should('have.text', '3 outputs (0.7 rBTC)')
29+
})
30+
31+
it('displays the address historical transactions', function(){
32+
cy.get('.transactions .transaction-box')
33+
.should('have.length', 3)
34+
35+
;[ [this.test_txid1,0.1], [this.test_txid2,0.2], [this.test_txid3,0.4] ].forEach(([txid, amount]) => {
36+
cy.contains('.transaction-box', txid)
37+
.should('exist')
38+
39+
.contains('.vout', this.test_addr)
40+
.should('have.class', 'active')
41+
42+
.find('.amount')
43+
.should('have.text', `${amount} rBTC`)
44+
})
45+
})
46+
47+
after(() => cy.task('bitcoind:mine'))
48+
})

tests/cypress/plugins/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ module.exports = (on, config) => {
3838
}
3939
return { txids, addr }
4040
}
41+
42+
, "bitcoind:newaddr": () =>
43+
bitcoind.getNewAddress()
44+
45+
, "bitcoind:sendto": ({ addr, amount }) =>
46+
bitcoind.sendToAddress(addr, amount)
4147
})
4248

4349
return config

0 commit comments

Comments
 (0)