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

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alepop committed Sep 11, 2017
1 parent 14b4172 commit b57707d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ class Login extends React.Component {
const invalidWord = mnemonic.find(word => !inDictionary(word));
if (invalidWord && (invalidWord.length >= 2 && invalidWord.length <= 8)) {
const validWord = findSimilarWord(invalidWord);
let message;
if (validWord) {
return `Word "${invalidWord}" is not on the passphrase Word List. Most similar word on the list is "${findSimilarWord(invalidWord)}"`;
message = `Word "${invalidWord}" is not on the passphrase Word List. Most similar word on the list is "${findSimilarWord(invalidWord)}"`;
} else {
message = `Word "${invalidWord}" is not on the passphrase Word List.`;
}
return message;
}

return 'Passphrase is not valid';
Expand Down
7 changes: 7 additions & 0 deletions src/components/login/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ describe('Login', () => {
expect(wrapper.find('.passphrase').text()).to.contain(expectedError);
});

it('should show error about incoret word if passphrase is have word not from dictionary', () => {
const passphrase = 'sdasd bomb asset salon coil symbol tiger engine assist pact pumpkin visit';
const expectedError = 'Word "sdasd" is not on the passphrase Word List.';
wrapper.find('.passphrase input').simulate('change', { target: { value: passphrase } });
expect(wrapper.find('.passphrase').text()).to.contain(expectedError);
});

it('should show error about invalid passhprase if it is incorrect', () => {
const passphrase = 'recipe bomb asset salon coil symbol apple engine assist pact pumpkin visit';
const expectedError = 'Passphrase is not valid';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/similarWord.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const mnemonic = require('bitcore-mnemonic');
import mnemonic from 'bitcore-mnemonic';

const MAX_WORD_LENGTH = 8;

Expand Down

0 comments on commit b57707d

Please sign in to comment.