]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blobdiff - tests.js
QR code shown on hover for certain bits of data
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / tests.js
index 843078f979f68ae5ca514f8dfc7706418edefb56..10d13a324f5dfb6d0aab2aa3068be44f3affc361 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -6,6 +6,11 @@ var page = require('webpage').create();
 var url = 'src/index.html';
 var testMaxTime = 10000;
 
+page.viewportSize = {
+    width: 1024,
+    height: 720
+};
+
 page.onResourceError = function(e) {
     console.log("Error loading " + e.url);
     phantom.exit();
@@ -3042,6 +3047,45 @@ page.open(url, function(status) {
 });
 },
 
+// Github issue 35
+// https://github.com/iancoleman/bip39/issues/35
+// QR Code support
+function() {
+page.open(url, function(status) {
+    // use entropy
+    page.evaluate(function() {
+        $(".generate").click();
+    });
+    waitForGenerate(function() {
+        var p = page.evaluate(function() {
+            // get position of mnemonic element
+            return $(".phrase").offset();
+        });
+        p.top = Math.ceil(p.top);
+        p.left = Math.ceil(p.left);
+        // check the qr code shows
+        page.sendEvent("mousemove", p.left+4, p.top+4);
+        var qrShowing = page.evaluate(function() {
+            return $(".qr-container").find("canvas").length > 0;
+        });
+        if (!qrShowing) {
+            console.log("QR Code does not show");
+            fail();
+        }
+        // check the qr code hides
+        page.sendEvent("mousemove", p.left-4, p.top-4);
+        var qrHidden = page.evaluate(function() {
+            return $(".qr-container").find("canvas").length == 0;
+        });
+        if (!qrHidden) {
+            console.log("QR Code does not hide");
+            fail();
+        }
+        next();
+    });
+});
+},
+
 
 // If you wish to add more tests, do so here...