Skip to content

Commit

Permalink
refactor(test): stub out token verification function
Browse files Browse the repository at this point in the history
  • Loading branch information
chidimo committed May 30, 2019
1 parent ded55f5 commit 6db4769
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 0 additions & 3 deletions middleware/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const AuthenticationMiddleware = {
},

verifyToken: (req, res, next) => {
if (Settings.skipTokenVerification()) {
return next();
}
const token = req.headers['x-access-token'];
if (!token) {
const msg = 'Include a valid token in the x-access-token header';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"start": "set NODE_ENV=production&node --require @babel/register ./bin/www ",
"devstart": "set NODE_ENV=development&set DEBUG=dev&nodemon --exec babel-node ./bin/www",
"lint": "./node_modules/.bin/eslint ./",
"test": "set NODE_ENV=test&set DEBUG=test&set DBNAME=testdb&nyc --reporter=html --reporter=text --reporter=lcov mocha -r @babel/register -r should",
"test": "set NODE_ENV=test&set DEBUG=test&set DBNAME=testdb&nyc --reporter=html --reporter=text --reporter=lcov mocha -r @babel/register -r should -r test/helpers/stubs.js",
"cover": "nyc report --reporter=text-lcov | coveralls",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"devtables": "set DEBUG=dev&set DBNAME=quick_credit&node --require @babel/register utils/createTables",
Expand Down
7 changes: 7 additions & 0 deletions test/helpers/stubs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sinon from 'sinon';

import AuthenticationMiddleware from '../../middleware/authentication';

sinon.stub(AuthenticationMiddleware, 'verifyToken').callsFake(
(req, res, next) => next()
);

0 comments on commit 6db4769

Please sign in to comment.