]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Add test for Pull Request 279 split phrase cards
authorIan Coleman <ian@iancoleman.io>
Sun, 10 Nov 2019 23:53:20 +0000 (10:53 +1100)
committerIan Coleman <ian@iancoleman.io>
Sun, 10 Nov 2019 23:53:20 +0000 (10:53 +1100)
src/js/index.js
tests/spec/tests.js

index 8caa0ed440cfc3dcc012a15c2615a83cc4094024..03a829677e3766f64f60b3d1c8225811d9fc7b50 100644 (file)
         calcForDerivationPath();
         // Show the word indexes
         showWordIndexes();
+        writeSplitPhrase(phrase);
     }
 
     function tabChanged() {
             if (DOM.phrase.val().length > 0) {
                 var newPhrase = convertPhraseToNewLanguage();
                 DOM.phrase.val(newPhrase);
-                writeSplitPhrase(newPhrase);
                 phraseChanged();
             }
             else {
         // show the words
         var words = mnemonic.toMnemonic(data);
         DOM.phrase.val(words);
-        writeSplitPhrase(words);
         // show the entropy
         var entropyHex = uint8ArrayToHex(data);
         DOM.entropy.val(entropyHex);
index 07918c2e400bd9e15f1496ec036fc9924d508de7..0ddbdba9486e6905de2731dd366dc98505973e0a 100644 (file)
@@ -4140,4 +4140,35 @@ fit('Converts mnemonics into raw entropy', function(done) {
     });
 });
 
+// Pull Request 279
+// Added Split Phrase Card Output
+fit('Shows split prase cards', function(done) {
+    var originalPhrase = "ugly charge strong giant once anchor capable october thumb inject dwarf legal alley mixture shoot";
+    var originalWords = originalPhrase.split(' ');
+    driver.findElement(By.css('.phrase'))
+        .sendKeys(originalPhrase);
+    driver.sleep(generateDelay).then(function() {
+        driver.findElement(By.css('.phraseSplit'))
+            .getAttribute("value")
+            .then(function(cardsStr) {
+                var cards = cardsStr.split("\n");
+                expect(cards.length).toBe(3);
+                // test all 2-of-3 combos can be used to form full phrase
+                var combos = [[0,1],[0,2],[1,2]];
+                for (var i=0; i<combos.length; i++) {
+                    var combo = combos[i];
+                    var a = combo[0];
+                    var b = combo[1];
+                    var phrase = cards[a] + " " + cards[b];
+                    // check all original words are present
+                    for (var j=0; j<originalWords.length; j++) {
+                        var originalWord = originalWords[j];
+                        expect(phrase).toContain(originalWord);
+                    }
+                }
+                done();
+            });
+    });
+});
+
 });