diff options
Diffstat (limited to 'tests.js')
-rw-r--r-- | tests.js | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -6,6 +6,11 @@ var page = require('webpage').create(); | |||
6 | var url = 'src/index.html'; | 6 | var url = 'src/index.html'; |
7 | var testMaxTime = 10000; | 7 | var testMaxTime = 10000; |
8 | 8 | ||
9 | page.viewportSize = { | ||
10 | width: 1024, | ||
11 | height: 720 | ||
12 | }; | ||
13 | |||
9 | page.onResourceError = function(e) { | 14 | page.onResourceError = function(e) { |
10 | console.log("Error loading " + e.url); | 15 | console.log("Error loading " + e.url); |
11 | phantom.exit(); | 16 | phantom.exit(); |
@@ -3042,6 +3047,45 @@ page.open(url, function(status) { | |||
3042 | }); | 3047 | }); |
3043 | }, | 3048 | }, |
3044 | 3049 | ||
3050 | // Github issue 35 | ||
3051 | // https://github.com/iancoleman/bip39/issues/35 | ||
3052 | // QR Code support | ||
3053 | function() { | ||
3054 | page.open(url, function(status) { | ||
3055 | // use entropy | ||
3056 | page.evaluate(function() { | ||
3057 | $(".generate").click(); | ||
3058 | }); | ||
3059 | waitForGenerate(function() { | ||
3060 | var p = page.evaluate(function() { | ||
3061 | // get position of mnemonic element | ||
3062 | return $(".phrase").offset(); | ||
3063 | }); | ||
3064 | p.top = Math.ceil(p.top); | ||
3065 | p.left = Math.ceil(p.left); | ||
3066 | // check the qr code shows | ||
3067 | page.sendEvent("mousemove", p.left+4, p.top+4); | ||
3068 | var qrShowing = page.evaluate(function() { | ||
3069 | return $(".qr-container").find("canvas").length > 0; | ||
3070 | }); | ||
3071 | if (!qrShowing) { | ||
3072 | console.log("QR Code does not show"); | ||
3073 | fail(); | ||
3074 | } | ||
3075 | // check the qr code hides | ||
3076 | page.sendEvent("mousemove", p.left-4, p.top-4); | ||
3077 | var qrHidden = page.evaluate(function() { | ||
3078 | return $(".qr-container").find("canvas").length == 0; | ||
3079 | }); | ||
3080 | if (!qrHidden) { | ||
3081 | console.log("QR Code does not hide"); | ||
3082 | fail(); | ||
3083 | } | ||
3084 | next(); | ||
3085 | }); | ||
3086 | }); | ||
3087 | }, | ||
3088 | |||
3045 | 3089 | ||
3046 | // If you wish to add more tests, do so here... | 3090 | // If you wish to add more tests, do so here... |
3047 | 3091 | ||