aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Coleman <ian@iancoleman.io>2019-11-11 10:53:20 +1100
committerIan Coleman <ian@iancoleman.io>2019-11-11 10:53:20 +1100
commita04946e23e479fd09f89eb2b2f541c38ebd62799 (patch)
tree9cf24d898cedff250fb40142ee31e60b43072204
parent700294714c39cb6e8226b960671a33dc93362edc (diff)
downloadBIP39-a04946e23e479fd09f89eb2b2f541c38ebd62799.tar.gz
BIP39-a04946e23e479fd09f89eb2b2f541c38ebd62799.tar.zst
BIP39-a04946e23e479fd09f89eb2b2f541c38ebd62799.zip
Add test for Pull Request 279 split phrase cards
-rw-r--r--src/js/index.js3
-rw-r--r--tests/spec/tests.js31
2 files changed, 32 insertions, 2 deletions
diff --git a/src/js/index.js b/src/js/index.js
index 8caa0ed..03a8296 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -264,6 +264,7 @@
264 calcForDerivationPath(); 264 calcForDerivationPath();
265 // Show the word indexes 265 // Show the word indexes
266 showWordIndexes(); 266 showWordIndexes();
267 writeSplitPhrase(phrase);
267 } 268 }
268 269
269 function tabChanged() { 270 function tabChanged() {
@@ -432,7 +433,6 @@
432 if (DOM.phrase.val().length > 0) { 433 if (DOM.phrase.val().length > 0) {
433 var newPhrase = convertPhraseToNewLanguage(); 434 var newPhrase = convertPhraseToNewLanguage();
434 DOM.phrase.val(newPhrase); 435 DOM.phrase.val(newPhrase);
435 writeSplitPhrase(newPhrase);
436 phraseChanged(); 436 phraseChanged();
437 } 437 }
438 else { 438 else {
@@ -493,7 +493,6 @@
493 // show the words 493 // show the words
494 var words = mnemonic.toMnemonic(data); 494 var words = mnemonic.toMnemonic(data);
495 DOM.phrase.val(words); 495 DOM.phrase.val(words);
496 writeSplitPhrase(words);
497 // show the entropy 496 // show the entropy
498 var entropyHex = uint8ArrayToHex(data); 497 var entropyHex = uint8ArrayToHex(data);
499 DOM.entropy.val(entropyHex); 498 DOM.entropy.val(entropyHex);
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index 07918c2..0ddbdba 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -4140,4 +4140,35 @@ fit('Converts mnemonics into raw entropy', function(done) {
4140 }); 4140 });
4141}); 4141});
4142 4142
4143// Pull Request 279
4144// Added Split Phrase Card Output
4145fit('Shows split prase cards', function(done) {
4146 var originalPhrase = "ugly charge strong giant once anchor capable october thumb inject dwarf legal alley mixture shoot";
4147 var originalWords = originalPhrase.split(' ');
4148 driver.findElement(By.css('.phrase'))
4149 .sendKeys(originalPhrase);
4150 driver.sleep(generateDelay).then(function() {
4151 driver.findElement(By.css('.phraseSplit'))
4152 .getAttribute("value")
4153 .then(function(cardsStr) {
4154 var cards = cardsStr.split("\n");
4155 expect(cards.length).toBe(3);
4156 // test all 2-of-3 combos can be used to form full phrase
4157 var combos = [[0,1],[0,2],[1,2]];
4158 for (var i=0; i<combos.length; i++) {
4159 var combo = combos[i];
4160 var a = combo[0];
4161 var b = combo[1];
4162 var phrase = cards[a] + " " + cards[b];
4163 // check all original words are present
4164 for (var j=0; j<originalWords.length; j++) {
4165 var originalWord = originalWords[j];
4166 expect(phrase).toContain(originalWord);
4167 }
4168 }
4169 done();
4170 });
4171 });
4172});
4173
4143}); 4174});