aboutsummaryrefslogtreecommitdiff
path: root/node_modules/express-validator/test/sanitizeHeadersTest.js
diff options
context:
space:
mode:
authornanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-21 06:29:31 +0000
committernanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-21 06:29:31 +0000
commitee8e1a13b60a6adfdc691b2a9b57289188397641 (patch)
tree096633208d9b8b6b59b67f4034a0cbb41e1f4c5d /node_modules/express-validator/test/sanitizeHeadersTest.js
parent689df70a38ace2f88cfef6ab50f10dc546b48f00 (diff)
need pull
Diffstat (limited to 'node_modules/express-validator/test/sanitizeHeadersTest.js')
-rw-r--r--node_modules/express-validator/test/sanitizeHeadersTest.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/node_modules/express-validator/test/sanitizeHeadersTest.js b/node_modules/express-validator/test/sanitizeHeadersTest.js
new file mode 100644
index 0000000..9168eba
--- /dev/null
+++ b/node_modules/express-validator/test/sanitizeHeadersTest.js
@@ -0,0 +1,45 @@
+var chai = require('chai');
+var expect = chai.expect;
+var request = require('supertest');
+
+var app;
+function validation(req, res) {
+ req.sanitizeHeaders('x-custom-header').trim();
+ res.send(req.headers);
+}
+
+function pass(body) {
+ expect(body).to.have.property('x-custom-header', 'space');
+}
+function fail(body) {
+ expect(body).to.have.property('x-custom-header').and.to.not.equal('space');
+}
+
+function getRoute(path, data, test, done) {
+ request(app)
+ .get(path)
+ .set('x-custom-header', 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('#sanitizeHeaders', function() {
+ describe('GET tests', function() {
+ it('should return property and sanitized value when headers param is present', function(done) {
+ getRoute('/', 'space ', pass, done);
+ });
+
+ it('should not return property when headers param is missing', function(done) {
+ getRoute('/', null, fail, done);
+ });
+ });
+});