Skip to content

Commit 077c6d8

Browse files
committed
all services tested
1 parent e0f99cc commit 077c6d8

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# snipe
22

3-
[![Build Status](https://travis-ci.org/EnsembleLab/snipe.svg?branch=master)](https://travis-ci.org/EnsembleLab/snipe)
3+
[![Build Status](https://travis-ci.org/EnsembleLab/snipe.svg?branch=master)](https://travis-ci.org/EnsembleLab/snipe) [![codecov](https://codecov.io/gh/EnsembleLab/snipe/branch/master/graph/badge.svg)](https://codecov.io/gh/EnsembleLab/snipe)
4+
45

56

67
Freelance Platform

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"crypto": "0.0.3",
4040
"debug": "^2.6.3",
4141
"express": "^4.15.2",
42+
"express-validator": "^3.1.2",
4243
"lodash": "^4.17.4",
4344
"mongoose": "^4.9.0",
4445
"q": "^1.4.1",

services/validator/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
"use strict";
22
var util = require('util');
33
var debug = require('debug')('validator');
4+
var _ = require('lodash');
45

56
module.exports = function(req, res, next){
67
debug('starting validation check.');
78
debug('What we got: ', req.body);
89
var parameters = req._required;
10+
var ignores = req._ignored;
911
if(parameters.length){
1012
var last = parameters.length - 1;
1113
for(var n in parameters){
1214
if(parameters[n]){
1315
debug('validating '+parameters[n]);
1416
req.check(parameters[n], parameters[n]+' is required').notEmpty();
15-
if(parameters[n] === 'otptransactionidentifier' || parameters[n] === 'trxreference' || parameters[n] === 'trxauthorizeid'){ /* jshint ignore:line */
17+
if(_.indexOf(parameters[n]) > -1){ /* jshint ignore:line */
1618
// Skip
1719
}else{
1820
req.sanitize(parameters[n]).escape();

test/config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
var chai = require('chai');
3+
chai.should();
4+
5+
var config = require('../config');
6+
7+
describe('#Config test', function(){
8+
it('should be an object', function(done){
9+
config.should.be.an('object');
10+
done();
11+
});
12+
});

test/services.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,21 @@ describe('#Encryption service test', function(){
160160
req.body.secureData = req.header('encryptedData');
161161
req.body.truth = demoDataHash;
162162
encryption.interpreter(req,res,next);
163-
setTimeout(100,function(){
163+
setTimeout(1000,function(){
164164
nextChecker.should.be.true; /* jslint ignore:line */
165+
nextChecker = false;
165166
});
166167
done();
167168
});
168-
169-
170-
169+
});
170+
171+
// Testing validation service
172+
173+
var validator = require('../services/validator');
174+
175+
describe('#Validation service test', function(){
176+
it('should exist as a function',function(done){
177+
validator.should.exist; /* jslint ignore:line */
178+
done();
179+
});
171180
});

0 commit comments

Comments
 (0)