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

Commit

Permalink
Add unit test for passhrase with extra white space error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yasharAyari committed Oct 10, 2017
1 parent 1727b3e commit 65d7766
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/passphraseInput/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,31 @@ describe('PassphraseInput', () => {
expect(wrapper.props().onChange).to.have.been.calledWith(passphrase, NOT_VALID_ERROR);
});

const WHITE_SPACE_AT_THE_BEGINNING_ERROR = 'Passphrase contains unnecessary whitespace at the beginning';
it("should call props.onChange with error='Passphrase contains unnecessary whitespace at the beginning'", () => {
const passphrase = ' wagon stock borrow episode laundry kitten salute link globe zero feed marble';
wrapper.find('input').simulate('change', { target: { value: passphrase } });
expect(wrapper.props().onChange).to.have.been
.calledWith(passphrase, WHITE_SPACE_AT_THE_BEGINNING_ERROR);
});

const WHITE_SPACE_AT_THE_END_ERROR = 'Passphrase contains unnecessary whitespace at the end';
it("should call props.onChange with error='Passphrase contains unnecessary whitespace at the end'", () => {
const passphrase = 'wagon stock borrow episode laundry kitten salute link globe zero feed marble ';
wrapper.find('input').simulate('change', { target: { value: passphrase } });
expect(wrapper.props().onChange).to.have.been
.calledWith(passphrase, WHITE_SPACE_AT_THE_END_ERROR);
});


const EXTRA_WHITE_SPACE_ERROR = 'Passphrase contains extra whitespace between words';
it("should call props.onChange with error='Passphrase contains extra whitespace between words'", () => {
const passphrase = 'wagon stock borrow episode laundry kitten salute link globe zero feed marble';
wrapper.find('input').simulate('change', { target: { value: passphrase } });
expect(wrapper.props().onChange).to.have.been
.calledWith(passphrase, EXTRA_WHITE_SPACE_ERROR);
});

it('should allow to change the input field to type="text" and back', () => {
expect(wrapper.find('input').props().type).to.equal('password');
wrapper.find('.show-passphrase-toggle').simulate('click');
Expand Down

0 comments on commit 65d7766

Please sign in to comment.