password_strength 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
1
  require "test_helper"
3
2
 
4
- class TestActiveModel < Test::Unit::TestCase
3
+ class TestActiveModel < Minitest::Test
5
4
  def setup
6
5
  PasswordStrength.enabled = true
7
6
  Object.class_eval { remove_const("User") } if defined?(User)
@@ -79,7 +78,7 @@ class TestActiveModel < Test::Unit::TestCase
79
78
  def test_lambda_incorrect_level
80
79
  User.validates_strength_of :password, :level => lambda {|u| 'incorrect_level' }
81
80
 
82
- assert_raise(ArgumentError, "The :level option must be one of [:weak, :good, :strong], a proc or a lambda") do
81
+ assert_raises(ArgumentError, "The :level option must be one of [:weak, :good, :strong], a proc or a lambda") do
83
82
  @user.update_attributes :username => "johndoe", :password => "johndoe"
84
83
  end
85
84
  end
@@ -1,42 +1,20 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1
+ <!doctype html>
2
+ <html>
4
3
  <head>
5
- <title>JavaScript unit test file</title>
6
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7
- <script src="jsunittest/jsunittest.js" type="text/javascript"></script>
8
- <script src="../app/assets/javascripts/password_strength.js" type="text/javascript"></script>
4
+ <meta charset="utf-8">
5
+ <title>PasswordStrength</title>
9
6
 
10
- <link rel="stylesheet" href="jsunittest/unittest.css" type="text/css" />
11
-
12
- <style type="text/css" media="screen">
13
- #logger p {
14
- background: #ffc;
15
- padding: 5px;
16
- }
17
- </style>
7
+ <link rel="stylesheet" href="../node_modules/qunitjs/qunit/qunit.css">
8
+ <script src="../node_modules/qunitjs/qunit/qunit.js"></script>
9
+ <script src="../node_modules/jquery/dist/jquery.js"></script>
10
+ <script src="../app/assets/javascripts/password_strength.js"></script>
11
+ <script src="../app/assets/javascripts/jquery_strength.js"></script>
18
12
  </head>
19
13
  <body>
20
14
 
21
- <div id="content">
22
- <div id="header">
23
- <h1>JavaScript unit test file</h1>
24
- <p>
25
- This file tests <strong>password_strength.js</strong>.
26
- </p>
27
- </div>
28
-
29
- <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
30
- <div id="testlog"></div>
31
-
32
- <!-- General debugger -->
33
- <div id="logger"></div>
34
-
35
- <!-- Put sample/test html here -->
36
- <div id="sample">
37
- </div>
38
- </div>
15
+ <div id="qunit"></div>
16
+ <div id="sample"></div>
39
17
 
40
- <script src="password_strength_test.js" type="text/javascript"></script>
18
+ <script src="password_strength_test.js"></script>
41
19
  </body>
42
20
  </html>
@@ -1,273 +1,343 @@
1
- new Test.Unit.Runner({
2
- setup: function() {
1
+ var strength;
2
+
3
+ QUnit.module("PasswordStrength", {
4
+ beforeEach: function() {
3
5
  strength = new PasswordStrength();
4
6
  strength.username = "johndoe";
5
7
  strength.password = "mypass";
6
- },
8
+ }
9
+ });
7
10
 
8
- teardown: function() {
9
- },
11
+ QUnit.test("shortcut", function(assert) {
12
+ strength = PasswordStrength.test("johndoe", "mypass");
10
13
 
11
- // Shortcut
12
- testShortcut: function() { with(this) {
13
- strength = PasswordStrength.test("johndoe", "mypass");
14
-
15
- assertEqual("johndoe", strength.username);
16
- assertEqual("mypass", strength.password);
17
- assertNotNull(strength.status);
18
- }},
19
-
20
- // Good strength
21
- testGoodStrength: function() { with(this) {
22
- strength.status = "good";
23
- assert(strength.isGood());
24
- assert(strength.isValid("good"));
25
- assertEqual(false, strength.isWeak());
26
- assertEqual(false, strength.isStrong());
27
- assertEqual(false, strength.isInvalid());
28
- }},
29
-
30
- // Weak strength
31
- testWeakStrength: function() { with(this) {
32
- strength.status = "weak";
33
- assert(strength.isWeak());
34
- assert(strength.isValid("weak"));
35
- assertEqual(false, strength.isStrong());
36
- assertEqual(false, strength.isGood());
37
- assertEqual(false, strength.isInvalid());
38
- }},
39
-
40
- // Strong strength
41
- testStrongStrength: function() { with(this) {
42
- strength.status = "strong";
43
- assert(strength.isStrong());
44
- assert(strength.isValid("strong"));
45
- assert(strength.isValid("good"));
46
- assertEqual(false, strength.isWeak());
47
- assertEqual(false, strength.isGood());
48
- assertEqual(false, strength.isInvalid());
49
- }},
50
-
51
- // Short password
52
- testShortPassword: function() { with(this) {
53
- strength.password = "a";
54
- strength.test();
14
+ assert.equal("johndoe", strength.username);
15
+ assert.equal("mypass", strength.password);
16
+ assert.ok(strength.status);
17
+ });
55
18
 
56
- assertEqual(0, strength.score);
57
- assertEqual("weak", strength.status);
58
- }},
19
+ QUnit.test("detect good strength", function(assert) {
20
+ strength.status = "good";
59
21
 
60
- // Password equals to username
61
- testPasswordEqualsToUsername: function() { with(this) {
62
- strength.username = "johndoe";
63
- strength.password = "johndoe";
64
- strength.test();
22
+ assert.ok(strength.isGood());
23
+ assert.ok(strength.isValid("good"));
24
+ assert.equal(strength.isWeak(), false);
25
+ assert.equal(strength.isStrong(), false);
26
+ assert.equal(strength.isInvalid(), false);
27
+ });
65
28
 
66
- assertEqual(0, strength.score);
67
- assertEqual("weak", strength.status);
68
- }},
29
+ QUnit.test("detect weak strength", function(assert) {
30
+ strength.status = "weak";
69
31
 
70
- // Strong password
71
- testStrongPassword: function() { with(this) {
72
- strength.password = "^P4ssw0rd$";
73
- strength.test();
32
+ assert.ok(strength.isWeak());
33
+ assert.ok(strength.isValid("weak"));
34
+ assert.equal(strength.isStrong(), false);
35
+ assert.equal(strength.isGood(), false);
36
+ assert.equal(strength.isInvalid(), false);
37
+ });
74
38
 
75
- assertEqual(100, strength.score);
76
- assertEqual("strong", strength.status);
77
- }},
39
+ QUnit.test("detect strong strength", function(assert) {
40
+ strength.status = "strong";
78
41
 
79
- // Weak password
80
- testWeakPassword: function() { with(this) {
81
- strength.password = "ytrewq";
82
- strength.test()
83
- assertEqual("weak", strength.status);
42
+ assert.ok(strength.isStrong());
43
+ assert.ok(strength.isValid("strong"));
44
+ assert.ok(strength.isValid("good"));
45
+ assert.equal(strength.isWeak(), false);
46
+ assert.equal(strength.isGood(), false);
47
+ assert.equal(strength.isInvalid(), false);
48
+ });
84
49
 
85
- strength.password = "asdfghjklm";
86
- strength.test();
87
- assertEqual("weak", strength.status);
88
- }},
50
+ QUnit.test("test short password", function(assert) {
51
+ strength.password = "abc";
52
+ strength.test();
89
53
 
90
- // Good password
91
- testGoodPassword: function() { with(this) {
92
- strength.password = "12345asdfg";
93
- strength.test();
94
- assertEqual("good", strength.status);
54
+ assert.equal(strength.score, 0);
55
+ assert.equal(strength.status, "weak");
56
+ });
95
57
 
96
- strength.password = "12345ASDFG";
97
- strength.test();
98
- assertEqual("good", strength.status);
58
+ QUnit.test("test password equal to username", function(assert) {
59
+ strength.username = "johndoe";
60
+ strength.password = "johndoe";
61
+ strength.test();
99
62
 
100
- strength.password = "12345Aa";
101
- strength.test();
102
- assertEqual("good", strength.status);
103
- }},
104
-
105
- // Penalize password with chars only
106
- testPenalizePasswordWithCharsOnly: function() { with(this) {
107
- strength.password = "abcdef";
108
- assertEqual(-15, strength.scoreFor("only_chars"));
109
- }},
110
-
111
- // Penalize password with numbers only
112
- testPenalizePasswordWithNumbersOnly: function() { with(this) {
113
- strength.password = "12345";
114
- assertEqual(-15, strength.scoreFor("only_numbers"));
115
- }},
116
-
117
- // Penalize password equals to username
118
- testPenalizePasswordEqualsToUsername: function() { with(this) {
119
- strength.username = "johndoe";
120
- strength.password = "johndoe";
121
- assertEqual(-100, strength.scoreFor("username"));
122
- }},
63
+ assert.equal(strength.score, 0);
64
+ assert.equal(strength.status, "weak");
65
+ });
123
66
 
124
- // Penalize password with username
125
- testPenalizePasswordWithUsername: function() { with(this) {
126
- strength.username = "johndoe";
127
- strength.password = "$1234johndoe^";
128
- assertEqual(-15, strength.scoreFor("username"));
129
- }},
130
-
131
- // Penalize number sequence
132
- testPenalizeNumberSequence: function() { with(this) {
133
- strength.password = "123";
134
- assertEqual(-15, strength.scoreFor("sequences"));
135
-
136
- strength.password = "123123";
137
- assertEqual(-30, strength.scoreFor("sequences"));
138
- }},
139
-
140
- // Penalize letter sequence
141
- testPenalizeLetterSequence: function() { with(this) {
142
- strength.password = "abc";
143
- assertEqual(-15, strength.scoreFor("sequences"));
144
-
145
- strength.password = "abcabc";
146
- assertEqual(-30, strength.scoreFor("sequences"));
147
- }},
148
-
149
- // Penalize number and letter sequence
150
- testPenalizeNumberAndLetterSequence: function() { with(this) {
151
- strength.password = "123abc";
152
- assertEqual(-30, strength.scoreFor("sequences"));
153
-
154
- strength.password = "123abc123abc";
155
- assertEqual(-60, strength.scoreFor("sequences"));
156
- }},
157
-
158
- // Penalize same letter sequence
159
- testPenalizeSameLetterSequence: function() { with(this) {
160
- strength.password = "aaa";
161
- assertEqual(-30, strength.scoreFor("sequences"));
162
- }},
163
-
164
- // Penalize same number sequence
165
- testPenalizeSameNumberSequence: function() { with(this) {
166
- strength.password = "111";
167
- assertEqual(-30, strength.scoreFor("sequences"));
168
- }},
169
-
170
- // Penalize reversed sequence
171
- testPenalizeReversedSequence: function() { with(this) {
172
- strength.password = "cba321";
173
- assertEqual(-30, strength.scoreFor("sequences"));
174
-
175
- strength.password = "cba321cba321";
176
- assertEqual(-60, strength.scoreFor("sequences"));
177
- }},
178
-
179
- // Penalize short password
180
- testPenalizeShortPassword: function() { with(this) {
181
- strength.password = "123";
182
- assertEqual(-100, strength.scoreFor("password_size"));
183
- }},
184
-
185
- // Penalize repetitions
186
- testPenalizeRepetitions: function() { with(this) {
187
- strength.password = "abcdabcdabcd";
188
- assertEqual(-36, strength.scoreFor("repetitions"));
189
- }},
190
-
191
- // Password length
192
- testPasswordLength: function() { with(this) {
193
- strength.password = "12345";
194
- assertEqual(-100, strength.scoreFor("password_size"));
195
- }},
196
-
197
- // Password with numbers
198
- testPasswordWithNumbers: function() { with(this) {
199
- strength.password = "123";
200
- assertEqual(5, strength.scoreFor("numbers"));
201
- }},
202
-
203
- // Password with symbols
204
- testPasswordWithSymbols: function() { with(this) {
205
- strength.password = "$!";
206
- assertEqual(5, strength.scoreFor("symbols"));
207
- }},
208
-
209
- // Password with uppercase and lowercase
210
- testPasswordWithUppercaseAndLowercase: function() { with(this) {
211
- strength.password = "aA";
212
- assertEqual(10, strength.scoreFor("uppercase_lowercase"));
213
- }},
214
-
215
- // numbers and chars
216
- testNumbersAndChars: function() { with(this) {
217
- strength.password = "a1";
218
- assertEqual(15, strength.scoreFor("numbers_chars"));
219
- }},
220
-
221
- // Numbers and symbols
222
- testNumbersAndSymbols: function() { with(this) {
223
- strength.password = "1$";
224
- assertEqual(15, strength.scoreFor("numbers_symbols"));
225
- }},
226
-
227
- // Symbols and chars
228
- testSymbolsAndChars: function() { with(this) {
229
- strength.password = "a$";
230
- assertEqual(15, strength.scoreFor("symbols_chars"));
231
- }},
232
-
233
- // Two char repetition
234
- testTwoCharRepetition: function() { with(this) {
235
- assertEqual(3, strength.repetitions("11221122", 2));
236
- }},
237
-
238
- // Three char repetition
239
- testThreeCharRepetition: function() { with(this) {
240
- assertEqual(3, strength.repetitions("123123123", 3));
241
- }},
242
-
243
- // Four char repetition
244
- testFourCharRepetition: function() { with(this) {
245
- assertEqual(4, strength.repetitions("abcdabcdabcd", 4));
246
- }},
247
-
248
- // Exclude option as regular expression
249
- testExcludeOptionAsRegularExpression: function() { with(this) {
250
- strength.password = "password with whitespaces";
251
- strength.exclude = /\s/;
252
- strength.test();
67
+ QUnit.test("test strong password", function(assert) {
68
+ strength.password = "^P4ssw0rd$";
69
+ strength.test();
70
+
71
+ assert.equal(strength.score, 100);
72
+ assert.equal(strength.status, "strong");
73
+ });
74
+
75
+ QUnit.test("test weak password", function(assert) {
76
+ strength.password = "ytrewq";
77
+ strength.test()
78
+ assert.equal(strength.status, "weak");
79
+
80
+ strength.password = "asdfghjklm";
81
+ strength.test();
82
+ assert.equal(strength.status, "weak");
83
+ });
84
+
85
+ QUnit.test("test good password", function(assert) {
86
+ strength.password = "12345asdfg";
87
+ strength.test();
88
+ assert.equal(strength.status, "good");
89
+
90
+ strength.password = "12345ASDFG";
91
+ strength.test();
92
+ assert.equal(strength.status, "good");
93
+
94
+ strength.password = "12345Aa";
95
+ strength.test();
96
+ assert.equal(strength.status, "good");
97
+ });
98
+
99
+ QUnit.test("penalize password with chars-only", function(assert) {
100
+ strength.password = "abcdef";
101
+ assert.equal(strength.scoreFor("only_chars"), -15);
102
+ });
103
+
104
+ QUnit.test("penalize password numbers-only", function(assert) {
105
+ strength.password = "12345";
106
+ assert.equal(strength.scoreFor("only_numbers"), -15);
107
+ });
108
+
109
+ QUnit.test("penalize password equal to username", function(assert) {
110
+ strength.username = "johndoe";
111
+ strength.password = "johndoe";
112
+ assert.equal(strength.scoreFor("username"), -100);
113
+ });
114
+
115
+ QUnit.test("penalize password that contains username", function(assert) {
116
+ strength.username = "johndoe";
117
+ strength.password = "$1234johndoe^";
118
+ assert.equal(strength.scoreFor("username"), -15);
119
+ });
120
+
121
+ QUnit.test("penalize number sequence", function(assert) {
122
+ strength.password = "123";
123
+ assert.equal(strength.scoreFor("sequences"), -15);
124
+
125
+ strength.password = "123123";
126
+ assert.equal(strength.scoreFor("sequences"), -30);
127
+ });
128
+
129
+ QUnit.test("penalize letter sequence", function(assert) {
130
+ strength.password = "abc";
131
+ assert.equal(strength.scoreFor("sequences"), -15);
132
+
133
+ strength.password = "abcabc";
134
+ assert.equal(strength.scoreFor("sequences"), -30);
135
+ });
253
136
 
254
- assertEqual("invalid", strength.status);
255
- assert(strength.isInvalid());
256
- assertEqual(false, strength.isValid());
257
- }},
137
+ QUnit.test("penalize number and letter sequence", function(assert) {
138
+ strength.password = "123abc";
139
+ assert.equal(strength.scoreFor("sequences"), -30);
258
140
 
259
- // Set common words
260
- testSetCommonWords: function() { with(this) {
261
- assert(PasswordStrength.commonWords.length > 500);
262
- }},
141
+ strength.password = "123abc123abc";
142
+ assert.equal(strength.scoreFor("sequences"), -60);
143
+ });
144
+
145
+ QUnit.test("penalize same letter sequence", function(assert) {
146
+ strength.password = "aaa";
147
+ assert.equal(strength.scoreFor("sequences"), -30);
148
+ });
149
+
150
+ QUnit.test("penalize same number sequence", function(assert) {
151
+ strength.password = "111";
152
+ assert.equal(strength.scoreFor("sequences"), -30);
153
+ });
154
+
155
+ QUnit.test("penalize reversed sequence", function(assert) {
156
+ strength.password = "cba321";
157
+ assert.equal(strength.scoreFor("sequences"), -30);
158
+
159
+ strength.password = "cba321cba321";
160
+ assert.equal(strength.scoreFor("sequences"), -60);
161
+ });
162
+
163
+ QUnit.test("penalize short password", function(assert) {
164
+ strength.password = "123";
165
+ assert.equal(strength.scoreFor("password_size"), -100);
166
+ });
167
+
168
+ QUnit.test("penalize repetitions", function(assert) {
169
+ strength.password = "abcdabcdabcd";
170
+ assert.equal(strength.scoreFor("repetitions"), -36);
171
+ });
172
+
173
+ QUnit.test("penalize password length", function(assert) {
174
+ strength.password = "12345";
175
+ assert.equal(strength.scoreFor("password_size"), -100);
176
+ });
263
177
 
264
- // Reject common passwords
265
- testRejectCommonPasswords: function() { with(this) {
266
- strength.password = PasswordStrength.commonWords[0];
178
+ QUnit.test("reward password with numbers", function(assert) {
179
+ strength.password = "123";
180
+ assert.equal(strength.scoreFor("numbers"), 5);
181
+ });
182
+
183
+ QUnit.test("reward password with symbols", function(assert) {
184
+ strength.password = "$!";
185
+ assert.equal(strength.scoreFor("symbols"), 5);
186
+ });
187
+
188
+ QUnit.test("reward mixed-case passwords", function(assert) {
189
+ strength.password = "aA";
190
+ assert.equal(strength.scoreFor("uppercase_lowercase"), 10);
191
+ });
192
+
193
+ QUnit.test("reward password that contains both numbers and letters", function(assert) {
194
+ strength.password = "a1";
195
+ assert.equal(strength.scoreFor("numbers_chars"), 15);
196
+ });
197
+
198
+ QUnit.test("reward password that contains both numbers and symbols", function(assert) {
199
+ strength.password = "1$";
200
+ assert.equal(strength.scoreFor("numbers_symbols"), 15);
201
+ });
202
+
203
+ QUnit.test("reward password that contains symbols and chars", function(assert) {
204
+ strength.password = "a$";
205
+ assert.equal(strength.scoreFor("symbols_chars"), 15);
206
+ });
207
+
208
+ QUnit.test("detect two-chars repetitions", function(assert) {
209
+ assert.equal(strength.repetitions("11221122", 2), 3);
210
+ });
211
+
212
+ QUnit.test("detect three-chars repetitions", function(assert) {
213
+ assert.equal(strength.repetitions("123123123", 3), 3);
214
+ });
215
+
216
+ QUnit.test("detect four-chars repetitions", function(assert) {
217
+ assert.equal(strength.repetitions("abcdabcdabcd", 4), 4);
218
+ });
219
+
220
+ QUnit.test("use exclude option as regular expression", function(assert) {
221
+ strength.password = "password with whitespaces";
222
+ strength.exclude = /\s/;
223
+ strength.test();
224
+
225
+ assert.equal(strength.status, "invalid");
226
+ assert.ok(strength.isInvalid());
227
+ assert.equal(strength.isValid(), false);
228
+ });
229
+
230
+ QUnit.test("set common words", function(assert) {
231
+ assert.ok(PasswordStrength.commonWords.length > 500);
232
+ });
233
+
234
+ QUnit.test("reject common passwords", function(assert) {
235
+ strength.password = PasswordStrength.commonWords[0];
236
+ strength.test();
237
+
238
+ assert.equal(strength.status, "invalid");
239
+ assert.ok(strength.isInvalid());
240
+ assert.equal(strength.isValid(), false);
241
+ });
242
+
243
+ QUnit.test("reject long passwords using same character", function(assert) {
244
+ strength.password = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
267
245
  strength.test();
246
+ assert.equal(strength.status, "invalid");
247
+ // assert @strength.invalid?
248
+ // refute @strength.valid?
249
+ });
250
+
251
+ QUnit.module("PasswordStrength: jQuery integration", {
252
+ beforeEach: function() {
253
+ $("#sample").html('<input type="text" id="username"><input type="text" id="password">');
254
+ $("#username").val("johndoe");
255
+ $("#password").val("mypass");
256
+ },
257
+
258
+ afterEach: function() {
259
+ $("#sample").empty();
260
+ }
261
+ });
262
+
263
+ QUnit.test("test defaults", function(assert) {
264
+ $.strength("#username", "#password");
265
+ $("#password").trigger("keydown");
266
+
267
+ assert.equal($("img.strength").length, 1);
268
+ });
269
+
270
+ QUnit.test("custom callback", function(assert) {
271
+ assert.expect(5);
272
+
273
+ $.strength("#username", "#password", function(username, password, strength){
274
+ assert.ok($(username).is("#username"));
275
+ assert.ok($(password).is("#password"));
276
+ assert.equal(strength.username, "johndoe");
277
+ assert.equal(strength.password, "mypass");
278
+ assert.equal(strength.status, "weak");
279
+ });
280
+
281
+ $("#password").trigger("keydown");
282
+ });
283
+
284
+ QUnit.test("apply callback when username is triggered", function(assert) {
285
+ $.strength("#username", "#password");
286
+ $("#username").trigger("keydown");
287
+
288
+ assert.equal($("img.strength").length, 1);
289
+ });
290
+
291
+ QUnit.test("apply weak status to image", function(assert) {
292
+ $.strength("#username", "#password");
293
+ $("#password").trigger("keydown");
294
+
295
+ assert.equal($("img.weak").length, 1);
296
+ assert.equal($("img.strength").attr("src"), "/images/weak.png");
297
+ });
298
+
299
+ QUnit.test("apply good status to image", function(assert) {
300
+ $("#password").val("12345asdfg");
301
+ $.strength("#username", "#password");
302
+ $("#password").trigger("keydown");
303
+
304
+ assert.equal($("img.good").length, 1);
305
+ assert.equal($("img.strength").attr("src"), "/images/good.png");
306
+ });
307
+
308
+ QUnit.test("apply strong status to image", function(assert) {
309
+ $("#password").val("^P4ssw0rd$");
310
+ $.strength("#username", "#password");
311
+ $("#password").trigger("keydown");
312
+
313
+ assert.equal($("img.strong").length, 1);
314
+ assert.equal($("img.strength").attr("src"), "/images/strong.png");
315
+ });
316
+
317
+ QUnit.test("missing username element: use selector as text", function(assert) {
318
+ $("#password").val("^P4ssw0rd$");
319
+ $.strength("root", "#password", function(username, password, strength){
320
+ assert.equal(strength.username, "root");
321
+ assert.equal(strength.password, "^P4ssw0rd$");
322
+ });
323
+
324
+ $("#password").trigger("keydown");
325
+ });
326
+
327
+ QUnit.test("missing password element: use selector as text", function(assert) {
328
+ $.strength("#username", "mypass", function(username, password, strength){
329
+ assert.equal(strength.username, "johndoe");
330
+ assert.equal(strength.password, "mypass");
331
+ });
332
+
333
+ $("#username").trigger("keydown");
334
+ });
335
+
336
+ QUnit.test("test exclude option as regular expression", function(assert) {
337
+ $.strength("#username", "password with whitespaces", {exclude: /\s/}, function(username, password, strength){
338
+ assert.equal(strength.status, "invalid");
339
+ assert.ok(strength.isInvalid());
340
+ });
268
341
 
269
- assertEqual("invalid", strength.status);
270
- assert(strength.isInvalid());
271
- assertEqual(false, strength.isValid());
272
- }}
342
+ $("#username").trigger("keydown");
273
343
  });