Skip to content

Commit

Permalink
added unit test to addAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
eniolam1000752 committed Jun 3, 2022
1 parent 0d74b60 commit 0331565
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const props = {
onAddAccount: jest.fn(),
};

let accountFormInstance = null;

beforeEach(() => {
props.onAddAccount.mockReset();
render(<AddAccountForm {...props} />);
accountFormInstance = render(<AddAccountForm {...props} />);
});

describe('Generals', () => {
Expand Down Expand Up @@ -58,6 +60,20 @@ describe('Generals', () => {
expect(props.onAddAccount).toBeCalled();
});

it('should not trigger add account', () => {
const inputField = screen.getByTestId('recovery-1');

const pasteEvent = createEvent.paste(inputField, {
clipboardData: {
getData: () => 'below record evolve eye youth post control consider spice swamp hidden easily',
},
});

fireEvent(inputField, pasteEvent);
fireEvent.keyPress(inputField, { key: 'Shift', code: 16, charCode: 16 });
expect(props.onAddAccount).not.toBeCalled();
});

it('should not trigger add account with a wrong mneumoic secrete recovery phrase', () => {
const inputField = screen.getByTestId('recovery-1');

Expand All @@ -71,4 +87,11 @@ describe('Generals', () => {
fireEvent.click(screen.getByText('Continue'));
expect(props.onAddAccount).not.toBeCalled();
});

it('should show the network selector', () => {
props.settings.showNetwork = true;

accountFormInstance.rerender(<AddAccountForm {...props} />);
expect(screen.queryByText('Select Network')).toBeTruthy();
});
});

0 comments on commit 0331565

Please sign in to comment.