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

axios-mock-shim

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-mock-shim - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

33

dist/request.js

@@ -42,3 +42,3 @@ /* eslint-disable */

*/
function mockHandler({ method, svc, data }, mockReply) {
function mockHandler({ method, svc, config }, mockReply) {
const mock = this;

@@ -56,3 +56,3 @@ // handler choose

// config handling
mock[`on${firstUp(method)}`](svc, data)
mock[`on${firstUp(method)}`](svc, ...config)
.reply.apply(mock, isFn(handler) ? [handler] : handler);

@@ -89,4 +89,13 @@ }

const parent = this;
const { ReplyCache } = this;
const { ReplyCache, $options } = this;
const { snakifyData, beforeRequest } = $options;
const methodUp = method.toUpperCase();
const cacheToken = stringify(method, svc, data);
data = snakifyData ? snakifyKeys(data) : data;
let configs = {
method,
svc,
data,
config: configHandler({ methodUp, beforeRequest, data }),
};
// Return an object to define mock data & calling

@@ -104,17 +113,10 @@ return {

},
run: parent.runBuilder.apply(parent, [method, svc, data]),
run: parent.runBuilder.apply(parent, [configs]),
};
},
useMockRequest(method, svc, data = {}) {
useMockRequest(configs) {
const { method, svc, data } = configs;
const { normalRequest, $adapter, ReplyCache, $options } = this;
const { snakifyData, anyReply, beforeRequest } = $options;
const methodUp = method.toUpperCase();
const { anyReply } = $options;
const cacheToken = stringify(method, svc, data);
data = snakifyData ? snakifyKeys(data) : data;
let configs = {
method,
svc,
data,
config: configHandler({ methodUp, beforeRequest, data }),
};
// with mockReply defined & not yet cached

@@ -139,4 +141,3 @@ const hasCache = RequestCache.has(cacheToken);

const { beforeResponse } = $options;
const methodUp = method.toUpperCase();
if (!httpMethodList.has(methodUp))
if (!httpMethodList.has(method.toUpperCase()))
return warn('Invalid http method', method);

@@ -143,0 +144,0 @@ return $instance[method.toLowerCase()](svc, ...config).then(beforeResponse ? beforeResponse : (res) => res);

{
"name": "axios-mock-shim",
"version": "1.1.4",
"version": "1.1.5",
"description": "A plugin build for easily using axios-mock-adapter with axios",

@@ -5,0 +5,0 @@ "main": "./index.js",

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