mm
Advanced tools
Comparing version 0.1.6 to 0.1.7
0.1.7 / 2013-11-20 | ||
================== | ||
* http.request mock support mm.http.request({host: $host, url: $url}) | ||
* add npm image | ||
0.1.6 / 2013-07-04 | ||
@@ -3,0 +9,0 @@ ================== |
/*! | ||
* mm - lib/mm.js | ||
* Copyright(c) 2012 fengmk2 <fengmk2@gmail.com> | ||
* | ||
* Copyright(c) 2012 - 2013 fengmk2 <fengmk2@gmail.com> | ||
* MIT Licensed | ||
@@ -73,3 +74,3 @@ */ | ||
* mock return callback(null, data1, data2). | ||
* | ||
* | ||
* @param {Object} mod, module object | ||
@@ -99,3 +100,3 @@ * @param {String} method, mock module object method name. | ||
* mock return callback(null, data). | ||
* | ||
* | ||
* @param {Object} mod, module object | ||
@@ -112,3 +113,3 @@ * @param {String} method, mock module object method name. | ||
* mock return callback(null, null). | ||
* | ||
* | ||
* @param {Object} mod, module object | ||
@@ -128,4 +129,8 @@ * @param {String} method, mock module object method name. | ||
function matchURL(options, url) { | ||
function matchURL(options, params) { | ||
var url = params && params.url || params; | ||
var host = params && params.host; | ||
var pathname = options.path || options.pathname; | ||
var hostname = options.host || options.hostname; | ||
var match = false; | ||
@@ -135,4 +140,8 @@ if (pathname) { | ||
match = pathname === url; | ||
} else { | ||
} else if (url instanceof RegExp) { | ||
match = url.test(pathname); | ||
} else if (typeof host === 'string') { | ||
match = host === hostname; | ||
} else if (host instanceof RegExp) { | ||
match = host.test(hostname); | ||
} | ||
@@ -160,3 +169,4 @@ } | ||
* Mock http.request(). | ||
* @param {String|RegExp} url, request url path. | ||
* @param {String|RegExp|Object} url, request url path. | ||
* If url is Object, should be {url: $url, host: $host} | ||
* @param {String|Buffer} data, mock response data. | ||
@@ -173,3 +183,4 @@ * If data is Array, then res will emit `data` event many times. | ||
* Mock https.request(). | ||
* @param {String|RegExp} url, request url path. | ||
* @param {String|RegExp|Object} url, request url path. | ||
* If url is Object, should be {url: $url, host: $host} | ||
* @param {String|Buffer} data, mock response data. | ||
@@ -292,3 +303,3 @@ * If data is Array, then res will emit `data` event many times. | ||
var req = mockRequest(); | ||
if (callback) { | ||
@@ -326,4 +337,4 @@ req.on('response', callback); | ||
* @param {Integer} code exit code | ||
* @param {String} stdout | ||
* @param {String} stderr | ||
* @param {String} stdout | ||
* @param {String} stderr | ||
* @param {Integer} timeout stdout/stderr/close event emit timeout | ||
@@ -341,3 +352,3 @@ */ | ||
evt.emit('exit', code); | ||
}, timeout); | ||
}, timeout); | ||
}; | ||
@@ -353,2 +364,2 @@ | ||
return this; | ||
}; | ||
}; |
This software is licensed under the MIT License. | ||
Copyright (C) 2012 - 2013 by fengmk2 <fengmk2@gmail.com> | ||
Copyright (C) 2012 - 2013 fengmk2 <fengmk2@gmail.com> | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "mm", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "mock mate, mock http request, fs access and so on.", | ||
@@ -8,4 +8,4 @@ "main": "index.js", | ||
"test": "make test-all", | ||
"blanket": { | ||
"pattern": "//^((?!(node_modules|test)).)*$/", | ||
"blanket": { | ||
"pattern": "mm/lib", | ||
"data-cover-flags": { | ||
@@ -32,2 +32,3 @@ "debug": false | ||
}, | ||
"homepage": "http://github.com/fengmk2/mm", | ||
"repository": { | ||
@@ -40,4 +41,4 @@ "type": "git", | ||
], | ||
"author": "fengmk2 <fengmk2@gmail.com>", | ||
"author": "fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com/)", | ||
"license": "MIT" | ||
} |
mm (美眉,Mock伴侣) [![Build Status](https://secure.travis-ci.org/fengmk2/mm.png)](http://travis-ci.org/fengmk2/mm) [![Coverage Status](https://coveralls.io/repos/fengmk2/mm/badge.png)](https://coveralls.io/r/fengmk2/mm) | ||
======= | ||
[![NPM](https://nodei.co/npm/mm.png?downloads=true&stars=true)](https://nodei.co/npm/mm) | ||
![logo](https://raw.github.com/fengmk2/mm/master/logo.png) | ||
@@ -135,15 +137,15 @@ | ||
```bash | ||
$ git summary | ||
$ git summary | ||
project : mm | ||
repo age : 8 months | ||
active : 16 days | ||
commits : 41 | ||
repo age : 1 year, 1 month | ||
active : 21 days | ||
commits : 49 | ||
files : 15 | ||
authors : | ||
37 fengmk2 90.2% | ||
4 dead-horse 9.8% | ||
authors : | ||
45 fengmk2 91.8% | ||
4 dead-horse 8.2% | ||
``` | ||
## License | ||
## License | ||
@@ -150,0 +152,0 @@ (The MIT License) |
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
17391
319
1
173