From db509b67209b1e6f77fbd9f2ac4fc752169ae008 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Wed, 29 Oct 2014 21:14:32 +0100 Subject: [PATCH 1/2] Make module common js compliant --- lib/mock.js | 4 ++++ package.json | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/mock.js b/lib/mock.js index 5cfb3cf..9c550df 100644 --- a/lib/mock.js +++ b/lib/mock.js @@ -466,3 +466,7 @@ MockHttpServer.prototype = { // Instances should override this. } }; + +if (module) { + module.exports = MockHttpRequest; +} diff --git a/package.json b/package.json index a311419..5a0971c 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,27 @@ { - "name": "MockHttpRequest", - "description": "A mock implementation of XMLHttpRequest for unit testing", - "version": "1.0", - "keywords": ["testing", "unit", "mock", "ajax", "http", "request"], - "maintainers": [{ - "name": "Philipp von Weitershausen", - "email": "philipp@weitershausen.de", - "web": "http://philikon.de" - }], - "contributors": [{ - "name": "Philipp von Weitershausen", - "email": "philipp@weitershausen.de", - "web": "http://philikon.de" - }], - "bugs": "http://github.com/philikon/MockHttpRequest/issues", - "licenses": [{ - "name": "MIT", - "url": "http://www.opensource.org/licenses/mit-license.php" - }], - "repositories": [{ - "type": "git", - "url": "http://github.com/philikon/MockHttpRequest" - }], - "dependencies": [], - "homepage": "http://github.com/philikon/MockHttpRequest", + "name": "MockHttpRequest", + "main": "lib/mock.js", + "description": "A mock implementation of XMLHttpRequest for unit testing", + "version": "1.0", + "keywords": ["testing", "unit", "mock", "ajax", "http", "request"], + "maintainers": [{ + "name": "Philipp von Weitershausen", + "email": "philipp@weitershausen.de", + "web": "http://philikon.de" + }], + "contributors": [{ + "name": "Stephan Hoyer", + "email": "ste.hoyer@gmail.com" + }], + "bugs": "http://github.com/philikon/MockHttpRequest/issues", + "licenses": [{ + "name": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + }], + "repositories": [{ + "type": "git", + "url": "http://github.com/philikon/MockHttpRequest" + }], + "dependencies": [], + "homepage": "http://github.com/philikon/MockHttpRequest" } From b5fd0e2f497dc766def8797ac256e4d3be0512d8 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Wed, 29 Oct 2014 22:48:01 +0100 Subject: [PATCH 2/2] Export request mock and fake server --- lib/mock.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mock.js b/lib/mock.js index 9c550df..4e53356 100644 --- a/lib/mock.js +++ b/lib/mock.js @@ -467,6 +467,9 @@ MockHttpServer.prototype = { } }; -if (module) { - module.exports = MockHttpRequest; +if (module && module.exports) { + module.exports = { + request: MockHttpRequest, + server: MockHttpServer + }; }