| | 101 | |
| | 102 | test( 'only the first part of really long passwords should be checked', function () { |
| | 103 | function strength(password) { |
| | 104 | return passwordStrength(password, [], password); |
| | 105 | } |
| | 106 | |
| | 107 | function raw(password) { |
| | 108 | return zxcvbn(password).score; |
| | 109 | } |
| | 110 | |
| | 111 | // passwordStrength()'s character limit. |
| | 112 | var threshold = 128; |
| | 113 | |
| | 114 | // Create a long string of zero characters. |
| | 115 | var weak = new Array( 1 + threshold ).join('0'); |
| | 116 | |
| | 117 | // A password that is strong only after the threshold. |
| | 118 | var strong = ( weak + '1#2!aGcDeee' ); |
| | 119 | |
| | 120 | // Get WP's strength/score, for comparison. |
| | 121 | var score = strength( strong ); |
| | 122 | |
| | 123 | ok( score === strength( weak ), 'scores of really long passwords match, regardless of anything after the size limit' ); |
| | 124 | ok( score === raw( weak ), 'Zxcvbn gives the same score as WP for the first part of a long password' ); |
| | 125 | ok( score < raw( strong ), 'Zxcvbn gives a better score than WP for a password which is strong only after the size limit' ); |
| | 126 | }); |