Comparing version 1.3.1 to 2.0.0
@@ -232,4 +232,4 @@ 'use strict'; | ||
/** | ||
* mock urllib | ||
* @method App#mockUrllib | ||
* mock httpclient | ||
* @method App#mockHttpclient | ||
* @param {String} mockUrl - url | ||
@@ -243,5 +243,5 @@ * @param {String} mockMethod - http method | ||
*/ | ||
mockUrllib(mockUrl, mockMethod, mockResult) { | ||
mockHttpclient(mockUrl, mockMethod, mockResult) { | ||
if (!mockResult) { | ||
// app.mockUrllib(mockUrl, mockResult) | ||
// app.mockHttpclient(mockUrl, mockResult) | ||
mockResult = mockMethod; | ||
@@ -280,8 +280,8 @@ mockMethod = 'GET'; | ||
const urllib = this.urllib; | ||
const requestThunk = urllib.requestThunk; | ||
const httpclient = this.httpclient; | ||
const rawRequest = httpclient.request; | ||
mm(urllib, 'requestThunk', _request); | ||
mm(urllib, 'request', _request); | ||
mm(urllib, 'curl', _request); | ||
mm(httpclient, 'requestThunk', _request); | ||
mm(httpclient, 'request', _request); | ||
mm(httpclient, 'curl', _request); | ||
@@ -305,3 +305,3 @@ return this; | ||
urllib.emit('response', { | ||
httpclient.emit('response', { | ||
error: null, | ||
@@ -328,6 +328,11 @@ ctx: opt.ctx, | ||
} | ||
return yield requestThunk.call(urllib, url, opt); | ||
return yield rawRequest.call(httpclient, url, opt); | ||
} | ||
}, | ||
mockUrllib(...args) { | ||
this.deprecate('[egg-mock] Please use app.mockHttpclient instead of app.mockUrllib'); | ||
return this.mockHttpclient(...args); | ||
}, | ||
/** | ||
@@ -334,0 +339,0 @@ * @see mm#restore |
1.3.1 / 2017-01-12 | ||
2.0.0 / 2017-01-12 | ||
================== | ||
* fix: override 1.3.0 breaking change | ||
* refactor: use mockHttpclient instead of mockUrllib (#19) | ||
1.3.0 (deprecated) / 2017-01-12 | ||
================== | ||
* refactor: use mockHttpclient instead of mockUrllib (#19) | ||
1.2.1 / 2017-01-09 | ||
@@ -8,0 +13,0 @@ ================== |
{ | ||
"name": "egg-mock", | ||
"version": "1.3.1", | ||
"version": "2.0.0", | ||
"eggPlugin": { | ||
@@ -17,4 +17,4 @@ "name": "egg-mock" | ||
"test": "npm run lint && npm run test-local", | ||
"test-local": "egg-bin test -r intelli-espower-loader", | ||
"cov": "egg-bin cov -r intelli-espower-loader", | ||
"test-local": "egg-bin test", | ||
"cov": "egg-bin cov", | ||
"ci": "npm run lint && npm run cov", | ||
@@ -37,3 +37,3 @@ "autod": "autod", | ||
"autod": "^2.7.1", | ||
"egg": "^0.5.0", | ||
"egg": "^0.7.0", | ||
"egg-bin": "^1.7.0", | ||
@@ -50,9 +50,3 @@ "egg-ci": "^1.1.0", | ||
"ci": { | ||
"type": "travis, appveyor", | ||
"npminstall": true, | ||
"version": [ | ||
"4", | ||
"6" | ||
], | ||
"command": "ci" | ||
"version": "6, 7" | ||
}, | ||
@@ -72,8 +66,5 @@ "homepage": "https://github.com/eggjs/egg-mock", | ||
"engines": { | ||
"node": ">= 4.0.0" | ||
"node": ">= 6.0.0" | ||
}, | ||
"publishConfig": { | ||
"tag": "release-1" | ||
}, | ||
"author": "popomore <sakura9515@gmail.com>" | ||
} |
@@ -334,21 +334,21 @@ # egg-mock | ||
### app.mockUrllib(url, method, data) | ||
### app.mockHttpclient(url, method, data) | ||
Mock `ctx.curl` | ||
Mock httpclient request, e.g.: `ctx.curl` | ||
```js | ||
app.get('/', function*() { | ||
const ret = yield this.curl('https://eggjs.org '); | ||
const ret = yield this.curl('https://eggjs.org'); | ||
this.body = ret.data.toString(); | ||
}); | ||
app.mockUrllib('https://eggjs.org ', { | ||
// 模拟的参数,可以是 buffer / string / json, | ||
// 都会转换成 buffer | ||
// 按照请求时的 options.dataType 来做对应的转换 | ||
app.mockHttpclient('https://eggjs.org', { | ||
// can be buffer / string / json, | ||
// will auto convert to buffer | ||
// follow options.dataType to convert | ||
data: 'mock taobao', | ||
}); | ||
request(app.callback()) | ||
.post('/') | ||
.expect('mock taobao', done); | ||
.post('/') | ||
.expect('mock taobao', done); | ||
``` | ||
@@ -355,0 +355,0 @@ |
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
30757
748