This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more unit tests for forging components
- Loading branch information
Showing
6 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import { mount } from 'enzyme'; | ||
import DelegateStats from './delegateStats'; | ||
|
||
chai.use(sinonChai); | ||
|
||
describe('<DelegateStats />', () => { | ||
const delegate = { | ||
username: 'genesis_17', | ||
rate: 19, | ||
approval: 30, | ||
productivity: 99.2, | ||
}; | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<DelegateStats delegate={delegate} />); | ||
}); | ||
|
||
it('should render 3 Card components', () => { | ||
expect(wrapper.find('Card')).to.have.lengthOf(3); | ||
}); | ||
|
||
it('should render 3 CircularProgressbar components', () => { | ||
expect(wrapper.find('svg.CircularProgressbar')).to.have.lengthOf(3); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import { mount } from 'enzyme'; | ||
import ForgingComponent from './forgingComponent'; | ||
|
||
chai.use(sinonChai); | ||
|
||
|
||
describe('<ForgingComponent />', () => { | ||
let wrapper; | ||
const props = { | ||
account: { | ||
delegate: {}, | ||
}, | ||
peers: {}, | ||
statistics: {}, | ||
forgedBlocks: [], | ||
loadStats: () => {}, | ||
loadForgedBlocks: () => {}, | ||
}; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<ForgingComponent {...props} />); | ||
}); | ||
|
||
it('should render <ForgingTitle/>', () => { | ||
expect(wrapper.find('ForgingTitle')).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should render <ForgingStats/>', () => { | ||
expect(wrapper.find('ForgingStats')).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should render <DelegateStats/>', () => { | ||
expect(wrapper.find('DelegateStats')).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should render <ForgedBlocks/>', () => { | ||
expect(wrapper.find('ForgedBlocks')).to.have.lengthOf(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import { mount } from 'enzyme'; | ||
import ForgingStats from './forgingStats'; | ||
|
||
chai.use(sinonChai); | ||
|
||
|
||
describe('<ForgingStats />', () => { | ||
const account = { | ||
delegate: { | ||
username: 'genesis_17', | ||
rate: 19, | ||
approval: 30, | ||
productivity: 99.2, | ||
}, | ||
}; | ||
const statistics = { | ||
last24h: 321317, | ||
last7d: 3213179124, | ||
last30d: 321317912423, | ||
last365d: 32131791242342, | ||
}; | ||
const loadStats = () => {}; | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<ForgingStats account={account} statistics={statistics} | ||
loadStats={loadStats} />); | ||
}); | ||
|
||
it('should render 4 Card components', () => { | ||
expect(wrapper.find('Card')).to.have.lengthOf(4); | ||
}); | ||
|
||
it('should render Card component for Last 24 hours', () => { | ||
expect(wrapper.find('Card').at(0).text().trim()).to.equal('Last 24 hours 0.00321317 LSK'); | ||
}); | ||
|
||
it('should render Card component for Last 7 days', () => { | ||
expect(wrapper.find('Card').at(1).text().trim()).to.equal('Last 7 days 32.13179124 LSK'); | ||
}); | ||
|
||
it('should render Card component for Last 30 days', () => { | ||
expect(wrapper.find('Card').at(2).text().trim()).to.equal('Last 30 days 3,213.17912423 LSK'); | ||
}); | ||
|
||
it('should render Card component for Last 365 days', () => { | ||
expect(wrapper.find('Card').at(3).text().trim()).to.equal('Last 365 days 321,317.91242342 LSK'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import { mount } from 'enzyme'; | ||
import ForgingTitle from './forgingTitle'; | ||
|
||
chai.use(sinonChai); | ||
|
||
|
||
describe('<ForgingTitle />', () => { | ||
const account = { | ||
delegate: { | ||
username: 'genesis_17', | ||
rate: 19, | ||
approval: 30, | ||
productivity: 99.2, | ||
}, | ||
}; | ||
const statistics = { | ||
total: 132423, | ||
}; | ||
const loadStats = () => {}; | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<ForgingTitle | ||
account={account} statistics={statistics} loadStats={loadStats}/>); | ||
}); | ||
|
||
it('should render 1 Card component', () => { | ||
expect(wrapper.find('Card')).to.have.lengthOf(1); | ||
}); | ||
|
||
it('should render h2 with delegate name', () => { | ||
expect(wrapper.find('h2').text()).to.equal(account.delegate.username); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import chai, { expect } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import { mount } from 'enzyme'; | ||
import { Provider } from 'react-redux'; | ||
import Forging from './'; | ||
import store from '../../store'; | ||
|
||
chai.use(sinonChai); | ||
|
||
|
||
describe('<Forging />', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Provider store={store}><Forging /></Provider>); | ||
}); | ||
|
||
it('should render 1 <ForgingComponent/>', () => { | ||
expect(wrapper.find('ForgingComponent')).to.have.lengthOf(1); | ||
}); | ||
}); |