From ee8e1a13b60a6adfdc691b2a9b57289188397641 Mon Sep 17 00:00:00 2001 From: nanalelfe Date: Thu, 21 Jul 2016 02:29:31 -0400 Subject: need pull --- .../test/nestedInputSanitizeTest.js | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 node_modules/express-validator/test/nestedInputSanitizeTest.js (limited to 'node_modules/express-validator/test/nestedInputSanitizeTest.js') diff --git a/node_modules/express-validator/test/nestedInputSanitizeTest.js b/node_modules/express-validator/test/nestedInputSanitizeTest.js new file mode 100644 index 0000000..18b6fcd --- /dev/null +++ b/node_modules/express-validator/test/nestedInputSanitizeTest.js @@ -0,0 +1,40 @@ +var chai = require('chai'); +var expect = chai.expect; +var request = require('supertest'); + +var app; +function validation(req, res) { + req.sanitize(['user', 'fields', 'email']).trim(); + res.send( req.body ); +} + +function pass(body) { + expect(body).to.have.deep.property('user.fields.email', 'test@example.com'); +} + +function postRoute(path, data, test, done) { + request(app) + .post(path) + .send(data) + .end(function(err, res) { + test(res.body); + done(); + }); +} + +// This before() is required in each set of tests in +// order to use a new validation function in each file +before(function() { + delete require.cache[require.resolve('./helpers/app')]; + app = require('./helpers/app')(validation); +}); + +describe('#nestedInputSanitizers', function() { + describe('POST tests', function() { + + it('should return property and sanitized value', function(done) { + postRoute('/', { user: { fields: { email: ' test@example.com ' } } }, pass, done); + }); + + }); +}); \ No newline at end of file -- cgit v1.2.3