diff --git a/package.json b/package.json index 6c63505..8ca2dc3 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test/index.spec.js b/test/index.spec.js index 77d5dfa..71a9420 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -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', () => { @@ -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()', () => { @@ -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'); + }); });