[Pkg-javascript-commits] [node-mocks-http] 229/296: Emitting send and end events at json call

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:39 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 ae6c785d5a741a517e0f6a4602ba580e21a6add4
Author: Artem Molonosov <artem.molonosov at itsolutions.es>
Date:   Fri May 8 10:59:44 2015 +0200

    Emitting send and end events at json call
---
 lib/mockResponse.js           |  4 ++++
 test/lib/mockResponse.spec.js | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/lib/mockResponse.js b/lib/mockResponse.js
index eacc555..bc49230 100644
--- a/lib/mockResponse.js
+++ b/lib/mockResponse.js
@@ -242,6 +242,10 @@ function createResponse(options) {
                 _data += JSON.stringify(b);
             }
         }
+
+        mockResponse.emit('send');
+        mockResponse.emit('end');
+
     };
 
     /**
diff --git a/test/lib/mockResponse.spec.js b/test/lib/mockResponse.spec.js
index d34a6d4..e68956f 100644
--- a/test/lib/mockResponse.spec.js
+++ b/test/lib/mockResponse.spec.js
@@ -465,9 +465,27 @@ describe('mockResponse', function() {
 
     // TODO: fix in 2.0; method should mimic Express Response.json()
     describe('.json()', function() {
+      var response;
+
+      beforeEach(function() {
+        response = mockResponse.createResponse();
+        sinon.spy(response, 'emit');
+      });
+
+      afterEach(function() {
+        response.emit.restore();
+        response = null;
+      });
 
       it('method should mimic Express Response.json()');
 
+      it('should emit send and end events', function() {
+        response.json({});
+        expect(response.emit).to.have.been.calledTwice;
+        expect(response.emit).to.have.been.calledWith('send');
+        expect(response.emit).to.have.been.calledWith('end');
+      });
+
     });
 
     // TODO: fix in 2.0; method should mimic Express Response.redirect()

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