-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69b3743
commit b0a091a
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var passwordValidator = require('../index'); | ||
|
||
describe('Password Validator', function() { | ||
|
||
it('should return false when password is undefined.', function() { | ||
|
||
var result = passwordValidator.validate(); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return true when password is valid.', function(){ | ||
var result = passwordValidator.validate("felipe*&^NevesBrit0"); | ||
expect(result.valid).to.equal(true); | ||
}); | ||
|
||
it('should return false when password is less than min length.', function(){ | ||
var result = passwordValidator.validate("felipe*&^NevesBrit0", {min: 399}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password is more than max length.', function(){ | ||
var result = passwordValidator.validate("felipe*&^NevesBrit0", {max: 3}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password has no lowercase.', function(){ | ||
var result = passwordValidator.validate("FELIPENEVESBRITO1234**9", {lowercase: true}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password has no uppercase.', function(){ | ||
var result = passwordValidator.validate("felipenevesbrito4**9", {uppercase: true}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password has no numbers.', function(){ | ||
var result = passwordValidator.validate("felipenGevesbrito**", {numbers: true}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password has no special characters.', function(){ | ||
var result = passwordValidator.validate("felipenevesbrFFito49", {specialCharacters: true}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return false when password has prohibited word.', function(){ | ||
var result = passwordValidator.validate("felipenevesbr*FFito49", {prohibitedWords: ['felipe']}); | ||
expect(result.valid).to.equal(false); | ||
}); | ||
|
||
it('should return true when password has no prohibited words.', function(){ | ||
var result = passwordValidator.validate("felipenevesbr*FFito49", {prohibitedWords: ['Brazil']}); | ||
expect(result.valid).to.equal(true); | ||
}); | ||
|
||
it('should return false when password has all default values.', function(){ | ||
var result = passwordValidator.validate("felipenevesbr**90)FFito49"); | ||
expect(result.valid).to.equal(true); | ||
}); | ||
|
||
}); |