Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-mock

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-mock - npm Package Compare versions

Comparing version 3.1.2 to 3.2.0

13

app/extend/application.js

@@ -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('/')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc