Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.2.2",
"eslint-plugin-react": "^5.1.1",
"mocha": "^2.5.3",
"gulp": "^3.9.1",
"gulp-coveralls": "^0.1.4",
"gulp-eslint": "^2.0.0",
"gulp-istanbul": "^0.10.4",
"gulp-mocha": "^2.2.0",
"run-sequence": "^1.2.1"
"mocha": "^2.5.3",
"run-sequence": "^1.2.1",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0"
}
}
20 changes: 20 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
const chai = require('chai');
const assert = chai.assert;
const stupidPassword = require('../lib');
const sinon = require("sinon");
const sinonChai = require("sinon-chai");
const expect = chai.expect;
chai.use(sinonChai);

describe('stupidPassword.isStupid()', () => {
it('should pass for a stupid password', () => {
Expand Down Expand Up @@ -39,6 +43,14 @@ describe('stupidPassword.isStupid()', () => {
assert.isFalse(stupidPassword.check('Pass990ver'));
assert.isFalse(stupidPassword.check('ummoinnerEmbassava33'));
});

it("should call the String toLowerCase method", function () {
const lower = sinon.spy(String.prototype, 'toLowerCase');
stupidPassword.isStupid('password');
lower.restore();
sinon.assert.calledOnce(lower);
sinon.assert.calledOn(lower, 'password');
});
});

describe('stupidPassword.rateOfUsage()', () => {
Expand All @@ -59,4 +71,12 @@ describe('stupidPassword.rateOfUsage()', () => {
});
assert.isObject(stupidPassword.rateOfUsage('SpaceOdessey2001Clarke'));
});

it("should call the String toLowerCase method", function () {
const lower = sinon.spy(String.prototype, 'toLowerCase');
stupidPassword.isStupid('football');
lower.restore();
sinon.assert.calledOnce(lower);
sinon.assert.calledOn(lower, 'football');
});
});