Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Improve unit test coverage of SavedAccounts component
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Nov 9, 2017
1 parent f686b47 commit a1d1073
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/savedAccounts/savedAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SavedAccounts = ({
<TableCell>
{account.network === networks.customNode.code ?
account.address :
t((getNetwork(account.network) || {}).name)}
t(getNetwork(account.network).name)}
</TableCell>
<TableCell className={styles.iconCell} >
<IconButton icon='clear' className='forget-button'
Expand Down
41 changes: 35 additions & 6 deletions src/components/savedAccounts/savedAccounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,36 @@ import SavedAccounts from './savedAccounts';

const fakeStore = configureStore();

describe('SavedAccounts', () => {
describe.only('SavedAccounts', () => {
let wrapper;
let closeDialogSpy;
let accountSavedSpy;
const publicKey = 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88';
const savedAccounts = [
{
publicKey: 'hab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
network: 0,
},
{
network: 2,
publicKey,
address: 'http://localhost:4000',
},
{
network: 0,
publicKey,
},
];

const props = {
account: {
publicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
},
closeDialog: () => {},
accountSaved: () => {},
accountRemoved: () => {},
accountSwitched: () => {},
networkOptions: {},
publicKey: [],
networkOptions: {
code: 0,
},
publicKey,
savedAccounts: [],
t: key => key,
};
Expand Down Expand Up @@ -59,5 +74,19 @@ describe('SavedAccounts', () => {
const componentProps = wrapper.find(SavedAccounts).props();
expect(componentProps.accountSaved).to.have.been.calledWith();
});

it('should render InfoParagraph', () => {
wrapper.find('button.add-active-account-button').simulate('click');
expect(wrapper.find('InfoParagraph')).to.have.lengthOf(1);
});

it('should render savedAccounts.length table rows', () => {
wrapper.find('button.add-active-account-button').simulate('click');
wrapper.setProps({
...props,
savedAccounts,
});
expect(wrapper.find('TableRow')).to.have.lengthOf(savedAccounts.length);
});
});

0 comments on commit a1d1073

Please sign in to comment.