[Pkg-javascript-commits] [node-mocks-http] 285/296: Ensure .vary() method is compatible with Node 0.12

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

alteholz pushed a commit to branch master
in repository node-mocks-http.

commit ea5015836fbfda9763d0ebef3ff19f2d42a7318f
Author: Matt Hinchliffe <matt at maketea.co.uk>
Date:   Fri Nov 20 09:42:18 2015 +0000

    Ensure .vary() method is compatible with Node 0.12
---
 lib/mockResponse.js           |  8 +++++++-
 test/lib/mockResponse.spec.js | 10 ++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/mockResponse.js b/lib/mockResponse.js
index 2f21d27..14681a4 100644
--- a/lib/mockResponse.js
+++ b/lib/mockResponse.js
@@ -373,7 +373,13 @@ function createResponse(options) {
         fields = Array.isArray(fields) ? fields : [ fields ];
 
         fields = fields.filter(function(field) {
-            return !values.find(value => value.match(new RegExp(field, 'i')));
+            var regex = new RegExp(field, 'i');
+
+            var matches = values.filter(function(value) {
+                return value.match(regex);
+            });
+
+            return !matches.length;
         });
 
         values = values.concat(fields);
diff --git a/test/lib/mockResponse.spec.js b/test/lib/mockResponse.spec.js
index c3d4b5e..cea6223 100644
--- a/test/lib/mockResponse.spec.js
+++ b/test/lib/mockResponse.spec.js
@@ -322,18 +322,12 @@ describe('mockResponse', function() {
         expect(response.get('Vary')).to.equal('value1, value2');
       });
 
-      it('should not duplicate vary header values', function() {
+      it('should not duplicate vary header values (regardless of case)', function() {
         response.vary([ 'value1', 'value2' ]);
-        response.vary([ 'value1', 'value3' ]);
+        response.vary([ 'Value1', 'VALUE2', 'value3' ]);
         expect(response.get('Vary')).to.equal('value1, value2, value3');
       });
 
-      it('Should match vary header values regardless of case', function() {
-        response.vary('Value1');
-        response.vary([ 'value1', 'Value2' ]);
-        expect(response.get('Vary')).to.equal('Value1, Value2');
-      });
-
     });
 
     describe('.set()/.header()', function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git



More information about the Pkg-javascript-commits mailing list