Skip to content

Commit

Permalink
✅ Add test to accountCreated step
Browse files Browse the repository at this point in the history
  • Loading branch information
massao committed Jan 10, 2019
1 parent d12550d commit f3bcfac
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/components/registerV2/accountCreated.test.js
@@ -0,0 +1,45 @@
import React from 'react';
import PropTypes from 'prop-types';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { MemoryRouter } from 'react-router-dom';
import i18n from '../../i18n';
import { generatePassphrase } from '../../utils/passphrase';
import { extractAddress } from '../../utils/account';
import AccountCreated from './accountCreated';

describe('V2 Register Process - Account created', () => {
let wrapper;

const crypotObj = window.crypto || window.msCrypto;
const passphrase = generatePassphrase({
seed: [...crypotObj.getRandomValues(new Uint16Array(16))].map(x => (`00${(x % 256).toString(16)}`).slice(-2)),
});
const account = {
address: extractAddress(passphrase),
passphrase,
};

const options = {
context: { i18n },
childContextTypes: {
i18n: PropTypes.object.isRequired,
},
};

const props = {
account,
};

beforeEach(() => {
wrapper = mount(<MemoryRouter>
<AccountCreated {...props} />
</MemoryRouter>, options);
});

it('Should render with correct avatar and address', () => {
expect(wrapper.find('AccountVisual')).to.have.length(1);
expect(wrapper.find('AccountVisual').prop('address')).to.have.equal(account.address);
expect(wrapper.find('.address').text()).to.be.equal(account.address);
});
});

0 comments on commit f3bcfac

Please sign in to comment.