[Pkg-javascript-commits] [node-mocks-http] 281/296: Make mockRequest an event emitter.

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 103d3235d4ef4bc38dca317c7f9f1c9376fe9302
Author: Evan Shortiss <evan.shortiss at feedhenry.com>
Date:   Wed Oct 28 12:30:03 2015 -0400

    Make mockRequest an event emitter.
---
 lib/mockRequest.js           | 3 ++-
 test/lib/mockRequest.spec.js | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/mockRequest.js b/lib/mockRequest.js
index 4510c17..183c03e 100644
--- a/lib/mockRequest.js
+++ b/lib/mockRequest.js
@@ -31,6 +31,7 @@
 
 var url = require('url');
 var typeis = require('type-is');
+var events = require('events');
 
 var standardRequestOptions = [
   'method', 'url', 'originalUrl', 'path', 'params', 'session', 'cookies', 'headers', 'body', 'query', 'files'
@@ -52,7 +53,7 @@ function createRequest(options) {
 
     // creat mockRequest
 
-    var mockRequest = {};
+    var mockRequest = Object.create(events.EventEmitter.prototype);
 
     mockRequest.method = (options.method) ? options.method : 'GET';
     mockRequest.url = options.url || options.path || '';
diff --git a/test/lib/mockRequest.spec.js b/test/lib/mockRequest.spec.js
index 93b311a..5fdbcfd 100644
--- a/test/lib/mockRequest.spec.js
+++ b/test/lib/mockRequest.spec.js
@@ -22,6 +22,12 @@ describe('mockRequest', function() {
         request = mockRequest.createRequest();
       });
 
+      it('should have event emitter prototype functions', function () {
+        expect(request.on).to.be.a('function');
+        expect(request.once).to.be.a('function');
+        expect(request.emit).to.be.a('function');
+      });
+
       it('should return an object', function() {
         expect(request).to.be.an('object');
       });

-- 
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