Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add tests for #3999 fix (merged in #4000)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Jan 1, 2017
1 parent 8c52db5 commit 28e40ec
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 31 deletions.
3 changes: 2 additions & 1 deletion js/src/views/Account/Header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>
Expand Down
81 changes: 51 additions & 30 deletions js/src/views/Account/Header/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit 28e40ec

Please sign in to comment.