Comparing version 3.1.2 to 3.2.0
@@ -236,3 +236,3 @@ 'use strict'; | ||
* @param {String} mockUrl - url | ||
* @param {String} mockMethod - http method | ||
* @param {String|Array} mockMethod - http method | ||
* @param {Object} mockResult - you data | ||
@@ -248,5 +248,6 @@ * - data - buffer / string / json | ||
mockResult = mockMethod; | ||
mockMethod = 'GET'; | ||
mockMethod = '*'; | ||
} | ||
mockMethod = (mockMethod || 'GET').toUpperCase(); | ||
if (!Array.isArray(mockMethod)) mockMethod = [ mockMethod ]; | ||
mockMethod = mockMethod.map(method => (method || 'GET').toUpperCase()); | ||
@@ -290,2 +291,6 @@ if (!mockResult.status) { | ||
function matchMethod(method) { | ||
return mockMethod.some(m => m === '*' || m === method); | ||
} | ||
// support generator rather than callback and promise | ||
@@ -295,3 +300,3 @@ function* _request(url, opt) { | ||
opt.method = (opt.method || 'GET').toUpperCase(); | ||
if (url === mockUrl && opt.method === mockMethod) { | ||
if (url === mockUrl && matchMethod(opt.method)) { | ||
const response = { | ||
@@ -298,0 +303,0 @@ status: mockResult.status, |
3.2.0 / 2017-03-14 | ||
================== | ||
* feat: mockHttpClient support mock multi methods (#35) | ||
* test: remove userrole (#34) | ||
3.1.2 / 2017-03-05 | ||
@@ -3,0 +9,0 @@ ================== |
{ | ||
"name": "egg-mock", | ||
"version": "3.1.2", | ||
"version": "3.2.0", | ||
"eggPlugin": { | ||
@@ -5,0 +5,0 @@ "name": "egg-mock" |
@@ -350,2 +350,7 @@ # egg-mock | ||
}); | ||
// app.mockHttpclient('https://eggjs.org', 'get', mockResponse); // mock get | ||
// app.mockHttpclient('https://eggjs.org', [ 'get' , 'head' ], mockResponse); // mock get and head | ||
// app.mockHttpclient('https://eggjs.org', '*', mockResponse); // mock all methods | ||
// app.mockHttpclient('https://eggjs.org', mockResponse); // mock all methods by default | ||
request(app.callback()) | ||
@@ -352,0 +357,0 @@ .post('/') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37644
901
367