Comparing version 0.9.3 to 0.10.0
var path = require('path') | ||
, fs = require('fs') | ||
, globalIntercept = require('./intercept') | ||
, mixin = require('./mixin') | ||
, assert = require('assert') | ||
@@ -57,4 +58,8 @@ | ||
} | ||
if (scope._defaultReplyHeaders) { | ||
headers || (headers = {}); | ||
headers = mixin(scope._defaultReplyHeaders, headers); | ||
} | ||
if (headers !== undefined) { | ||
@@ -64,4 +69,3 @@ this.headers = {}; | ||
// makes sure all keys in headers are in lower case | ||
var key2; | ||
for (key2 in headers) { | ||
for (var key2 in headers) { | ||
if (headers.hasOwnProperty(key2)) { | ||
@@ -232,2 +236,7 @@ this.headers[key2.toLowerCase()] = headers[key2]; | ||
} | ||
function defaultReplyHeaders(headers) { | ||
this._defaultReplyHeaders = headers; | ||
return this; | ||
} | ||
@@ -250,2 +259,3 @@ function log(newLogger) { | ||
, matchHeader: matchHeader | ||
, defaultReplyHeaders: defaultReplyHeaders | ||
, log: log | ||
@@ -252,0 +262,0 @@ }; |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.9.3" | ||
, "version" : "0.10.0" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "contributors" : |
@@ -1128,1 +1128,18 @@ var nock = require('../.') | ||
}); | ||
tap.test("default reply headers work", function(t) { | ||
var scope = nock('http://default.reply.headers.com') | ||
.defaultReplyHeaders({'X-Powered-By': 'Meeee', 'X-Another-Header': 'Hey man!'}) | ||
.get('/') | ||
.reply(200, '', {A: 'b'}); | ||
function done(res) { | ||
t.deepEqual(res.headers, {'x-powered-by': 'Meeee', 'x-another-header': 'Hey man!', a: 'b'}); | ||
t.end(); | ||
} | ||
http.request({ | ||
host: 'default.reply.headers.com' | ||
, path: '/' | ||
}, done).end(); | ||
}); |
55297
14
1637