diff --git a/js/src/views/Account/Header/header.js b/js/src/views/Account/Header/header.js index c12c9c9a6c7..db98cf19c85 100644 --- a/js/src/views/Account/Header/header.js +++ b/js/src/views/Account/Header/header.js @@ -47,7 +47,8 @@ export default class Header extends Component { return null; } - const { address, meta } = account; + const { address } = account; + const meta = account.meta || {}; return ( <div className={ className }> diff --git a/js/src/views/Account/Header/header.spec.js b/js/src/views/Account/Header/header.spec.js index b8db221a269..5ae5104d2e4 100644 --- a/js/src/views/Account/Header/header.spec.js +++ b/js/src/views/Account/Header/header.spec.js @@ -46,45 +46,61 @@ function render (props = {}) { } describe('views/Account/Header', () => { - it('renders defaults', () => { - expect(render()).to.be.ok; - }); + describe('rendering', () => { + it('renders defaults', () => { + expect(render()).to.be.ok; + }); - it('renders null with no account', () => { - expect(render(null).find('div')).to.have.length(0); - }); + it('renders null with no account', () => { + expect(render(null).find('div')).to.have.length(0); + }); - it('renders the Balance', () => { - render({ balance: { balance: 'testing' } }); - const balance = component.find('Connect(Balance)'); + it('renders when no account meta', () => { + expect(render({ account: { address: ACCOUNT.address } })).to.be.ok; + }); - expect(balance).to.have.length(1); - expect(balance.props().account).to.deep.equal(ACCOUNT); - expect(balance.props().balance).to.deep.equal({ balance: 'testing' }); - }); + it('renders when no account description', () => { + expect(render({ account: { address: ACCOUNT.address, meta: { tags: [] } } })).to.be.ok; + }); + + it('renders when no account tags', () => { + expect(render({ account: { address: ACCOUNT.address, meta: { description: 'something' } } })).to.be.ok; + }); - it('renders the Certifications', () => { - render(); - const certs = component.find('Connect(Certifications)'); + describe('sections', () => { + it('renders the Balance', () => { + render({ balance: { balance: 'testing' } }); + const balance = component.find('Connect(Balance)'); - expect(certs).to.have.length(1); - expect(certs.props().address).to.deep.equal(ACCOUNT.address); - }); + expect(balance).to.have.length(1); + expect(balance.props().account).to.deep.equal(ACCOUNT); + expect(balance.props().balance).to.deep.equal({ balance: 'testing' }); + }); - it('renders the IdentityIcon', () => { - render(); - const icon = component.find('Connect(IdentityIcon)'); + it('renders the Certifications', () => { + render(); + const certs = component.find('Connect(Certifications)'); - expect(icon).to.have.length(1); - expect(icon.props().address).to.equal(ACCOUNT.address); - }); + expect(certs).to.have.length(1); + expect(certs.props().address).to.deep.equal(ACCOUNT.address); + }); + + it('renders the IdentityIcon', () => { + render(); + const icon = component.find('Connect(IdentityIcon)'); - it('renders the Tags', () => { - render(); - const tags = component.find('Tags'); + expect(icon).to.have.length(1); + expect(icon.props().address).to.equal(ACCOUNT.address); + }); - expect(tags).to.have.length(1); - expect(tags.props().tags).to.deep.equal(ACCOUNT.meta.tags); + it('renders the Tags', () => { + render(); + const tags = component.find('Tags'); + + expect(tags).to.have.length(1); + expect(tags.props().tags).to.deep.equal(ACCOUNT.meta.tags); + }); + }); }); describe('renderName', () => { @@ -97,6 +113,11 @@ describe('views/Account/Header', () => { render(); expect(instance.renderName()).not.to.be.null; }); + + it('renders when no address specified', () => { + render({ account: {} }); + expect(instance.renderName()).to.be.ok; + }); }); describe('renderTxCount', () => {