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

Commit

Permalink
Merge pull request #790 from LiskHQ/789-passphrase-e2e-tests
Browse files Browse the repository at this point in the history
Hot fix on passphrase utility - closes #789
  • Loading branch information
reyraa authored Sep 28, 2017
2 parents e5d7761 + 0b9df24 commit 8f27050
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/passphrase/passphraseVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class PassphraseConfirmator extends React.Component {
}

hideRandomWord(rand = Math.random()) {
const words = this.props.passphrase.trim().split(/\s+/);
const words = this.props.passphrase.trim().split(/\s+/).filter(item => item.length > 0);
const index = Math.floor(rand * (words.length - 1));

this.setState({
passphraseParts: this.props.passphrase.split(` ${words[index]} `),
passphraseParts: this.props.passphrase.split(words[index]),
missing: words[index],
answer: '',
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/passphrase/passphraseVerifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('PassphraseVerifier', () => {
const randomIndex = 0.6;
const expectedValues = {
passphraseParts: [
'survey stereo pool fortune oblige slight',
'goddess mistake sentence anchor pool',
'survey stereo pool fortune oblige slight ',
' goddess mistake sentence anchor pool',
],
missing: 'gravity',
answer: '',
Expand Down
4 changes: 2 additions & 2 deletions src/utils/passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const leftPadd = (str, pad, length) => {
* Resets previous settings and creates a step with a random length between 1.6% to 3.2%
*/
const init = (rand = Math.random()) => {
let step = Math.max((160 + Math.floor(rand * 160)));
step = step >= 0.01 ? step : step * 10;
let step = (160 + Math.floor(rand * 160)) / 100;
step = step >= 0.01 ? step : 0.1 + (step * 5);
return {
step,
percentage: 0,
Expand Down

0 comments on commit 8f27050

Please sign in to comment.