Skip to content

Commit

Permalink
- Fix issue with password requirement generation
Browse files Browse the repository at this point in the history
- Bump npm package version
- Add unit tests
  • Loading branch information
Xavier Sellier committed Sep 15, 2016
1 parent 265274d commit a8133ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Tests are written with mocha/chai.
```

## Changelog
1.1.3
- Fix issue with password requirement generation
- Add unit tests

1.1.2
- Remove lodash from dependencies
- Upgrade devDependencies
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function generatePassword(pOptions, pLength) {
}

var fillRequirement = function(asciiType) {
var numberOfType = generateNumber(1, (length - reservedChars));
var numberOfType = generateNumber(1, (length - reservedChars + 1));

for (index = 0; index < numberOfType; ++index) {
var max = available.length - 1;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "password-maker",
"version": "1.1.2",
"version": "1.1.3",
"description": "Generate a password randomly",
"main": "lib/index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions test/password-maker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,14 @@ describe("The password-maker", function() {

done();
});

it("should generate a password with lower, upper, number and symbol with size 4", function(done) {
for(var index = 0; index < 100; ++index) {
var result = passwordMaker.generatePassword(4);
expect(result).to.match(/[A-Z]/);
expect(result).to.match(/[-!$%^&*()_+|~=`{}\[\]:";'<>?,.\/#]/);
expect(result).to.match(/[0-9]/);
}
done();
});
});

0 comments on commit a8133ee

Please sign in to comment.