-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
46 lines (38 loc) · 1.06 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
describe('safe', function() {
var safe = require('./');
function assert(a, b) {
if (a !== b) {
throw new Error(a + ' not equal ' + b);
}
}
it('should be a terrible password', function() {
var ret = safe('1');
assert(ret.valid, false);
assert(ret.strength, 'terrible');
});
it('should be a simple password', function() {
var ret = safe('asdfghjkl');
assert(ret.valid, false);
assert(ret.strength, 'simple');
ret = safe('abcdefg');
assert(ret.valid, false);
assert(ret.strength, 'simple');
ret = safe('password');
assert(ret.valid, false);
assert(ret.strength, 'simple');
// valid simple password
ret = safe('yhnolku');
assert(ret.valid, true);
assert(ret.strength, 'simple');
});
it('should be a medium password', function() {
var ret = safe('yhnolkuT');
assert(ret.valid, true);
assert(ret.strength, 'medium');
});
it('should be a strong password', function() {
var ret = safe('yhnolkuT.');
assert(ret.valid, true);
assert(ret.strength, 'strong');
});
});