axios-mock-adapter
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -192,3 +192,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
module.exports = module.exports.default = MockAdapter; | ||
module.exports = MockAdapter; | ||
module.exports.default = MockAdapter; | ||
@@ -195,0 +196,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):"object"==typeof exports?exports.AxiosMockAdapter=t(require("axios")):e.AxiosMockAdapter=t(e.axios)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(){return function(e){var t=this;if(3!==arguments.length)return new Promise(function(n,r){u(t,n,r,e)});u(t,arguments[0],arguments[1],arguments[2])}.bind(this)}function o(){this.handlers=a.reduce(function(e,t){return e[t]=[],e},{}),this.replyOnceHandlers=[]}function i(e,t){o.call(this),e&&(this.axiosInstance=e,this.originalAdapter=e.defaults.adapter,this.delayResponse=t&&t.delayResponse>0?t.delayResponse:null,e.defaults.adapter=r.call(this))}function s(e,t,n){"any"===e?a.forEach(function(e){t[e].push(n)}):t[e].push(n)}var u=n(1),a=["get","post","head","delete","patch","put","options"];i.prototype.adapter=r,i.prototype.restore=function(){this.axiosInstance&&(this.axiosInstance.defaults.adapter=this.originalAdapter)},i.prototype.reset=o,a.concat("any").forEach(function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);i.prototype[t]=function(t,n,r){function o(o,u,a){var c=[t,n,r,o,u,a];return s(e,i.handlers,c),i}var i=this,t=void 0===t?/.*/:t;return{reply:o,replyOnce:function(o,u,a){var c=[t,n,r,o,u,a];return s(e,i.handlers,c),i.replyOnceHandlers.push(c),i},passThrough:function(){var r=[t,n];return s(e,i.handlers,r),i},networkError:function(){o(function(e){var t=new Error("Network Error");return t.config=e,Promise.reject(t)})},timeout:function(){o(function(e){var t=new Error("timeout of "+e.timeout+"ms exceeded");return t.config=e,t.code="ECONNABORTED",Promise.reject(t)})}}}}),e.exports=e.exports.default=i},function(e,t,n){"use strict";function r(e,t){return{status:e[0],data:i.isSimpleObject(e[1])?JSON.parse(JSON.stringify(e[1])):e[1],headers:e[2],config:t}}function o(e,t,n,o){o.baseURL&&o.url.substr(0,o.baseURL.length)===o.baseURL&&(o.url=o.url.slice(o.baseURL?o.baseURL.length:0)),o.adapter=null;var s=i.findHandler(e.handlers,o.method,o.url,o.data,o.params,o.headers);if(s)if(i.purgeIfReplyOnce(e,s),2===s.length)o.adapter=e.originalAdapter,e.axiosInstance.request(o).then(t,n);else if(s[3]instanceof Function){var u=s[3](o);u.then instanceof Function?u.then(function(s){i.settle(t,n,r(s,o),e.delayResponse)},function(t){e.delayResponse>0?setTimeout(function(){n(t)},e.delayResponse):n(t)}):i.settle(t,n,r(u,o),e.delayResponse)}else i.settle(t,n,r(s.slice(3),o),e.delayResponse);else i.settle(t,n,{status:404,config:o},e.delayResponse)}var i=n(2);e.exports=o},function(e,t,n){"use strict";function r(e,t){return g(e,t,{strict:!0})}function o(e,t){for(var n=e.length,r=0;r<n;r++){var o=e[r];if(t(o))return o}}function i(e,t,n,r,i,c){return o(e[t.toLowerCase()],function(e){return"string"==typeof e[0]?s(n,e[0])&&a(t,r,i,e[1])&&u(c,e[2]):e[0]instanceof RegExp?e[0].test(n)&&a(t,r,i,e[1])&&u(c,e[2]):void 0})}function s(e,t){return("/"===e[0]?e.substr(1):e)===("/"===t[0]?t.substr(1):t)}function u(e,t){return void 0===t||r(e,t)}function a(e,t,n,r){if(["delete","get","head","options"].indexOf(e.toLowerCase())>=0)return c(n,r?r.params:void 0);return f(t,r)}function c(e,t){return void 0===t||r(e,t)}function f(e,t){if(void 0===t)return!0;var n;try{n=JSON.parse(e)}catch(e){}return n?r(n,t):r(e,t)}function l(e,t){var n=e.replyOnceHandlers.indexOf(t);n>-1&&(e.replyOnceHandlers.splice(n,1),Object.keys(e.handlers).forEach(function(r){(n=e.handlers[r].indexOf(t))>-1&&e.handlers[r].splice(n,1)}))}function p(e,t,n,r){return r>0?void setTimeout(function(){p(e,t,n)},r):n.config&&n.config.validateStatus?void(n.config.validateStatus(n.status)?e(n):t(d("Request failed with status code "+n.status,n.config,n))):void(n.status>=200&&n.status<300?e(n):t(n))}function d(e,t,n){if(!v)return n;var r=new Error(e);return r.config=t,r.response=n,r}function h(e){return null!==e&&void 0!==e&&"[object Object]"===e.toString()}var y=n(3),g=n(4),v=!!y.create().defaults.headers;e.exports={find:o,findHandler:i,isSimpleObject:h,purgeIfReplyOnce:l,settle:p}},function(t,n){t.exports=e},function(e,t,n){function r(e){return null===e||void 0===e}function o(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&!(e.length>0&&"number"!=typeof e[0]))}function i(e,t,n){var i,f;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(a(e))return!!a(t)&&(e=s.call(e),t=s.call(t),c(e,t,n));if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}try{var l=u(e),p=u(t)}catch(e){return!1}if(l.length!=p.length)return!1;for(l.sort(),p.sort(),i=l.length-1;i>=0;i--)if(l[i]!=p[i])return!1;for(i=l.length-1;i>=0;i--)if(f=l[i],!c(e[f],t[f],n))return!1;return typeof e==typeof t}var s=Array.prototype.slice,u=n(5),a=n(6),c=e.exports=function(e,t,n){return n||(n={}),e===t||(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?n.strict?e===t:e==t:i(e,t,n))}},function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}t=e.exports="function"==typeof Object.keys?Object.keys:n,t.shim=n},function(e,t){function n(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();t=e.exports=o?n:r,t.supported=n,t.unsupported=r}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):"object"==typeof exports?exports.AxiosMockAdapter=t(require("axios")):e.AxiosMockAdapter=t(e.axios)}("undefined"!=typeof self?self:this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function r(){return function(e){var t=this;if(3!==arguments.length)return new Promise(function(n,r){u(t,n,r,e)});u(t,arguments[0],arguments[1],arguments[2])}.bind(this)}function o(){this.handlers=a.reduce(function(e,t){return e[t]=[],e},{}),this.replyOnceHandlers=[]}function i(e,t){o.call(this),e&&(this.axiosInstance=e,this.originalAdapter=e.defaults.adapter,this.delayResponse=t&&t.delayResponse>0?t.delayResponse:null,e.defaults.adapter=r.call(this))}function s(e,t,n){"any"===e?a.forEach(function(e){t[e].push(n)}):t[e].push(n)}var u=n(1),a=["get","post","head","delete","patch","put","options"];i.prototype.adapter=r,i.prototype.restore=function(){this.axiosInstance&&(this.axiosInstance.defaults.adapter=this.originalAdapter)},i.prototype.reset=o,a.concat("any").forEach(function(e){var t="on"+e.charAt(0).toUpperCase()+e.slice(1);i.prototype[t]=function(t,n,r){function o(o,u,a){var c=[t,n,r,o,u,a];return s(e,i.handlers,c),i}var i=this,t=void 0===t?/.*/:t;return{reply:o,replyOnce:function(o,u,a){var c=[t,n,r,o,u,a];return s(e,i.handlers,c),i.replyOnceHandlers.push(c),i},passThrough:function(){var r=[t,n];return s(e,i.handlers,r),i},networkError:function(){o(function(e){var t=new Error("Network Error");return t.config=e,Promise.reject(t)})},timeout:function(){o(function(e){var t=new Error("timeout of "+e.timeout+"ms exceeded");return t.config=e,t.code="ECONNABORTED",Promise.reject(t)})}}}}),e.exports=i,e.exports.default=i},function(e,t,n){"use strict";function r(e,t){return{status:e[0],data:i.isSimpleObject(e[1])?JSON.parse(JSON.stringify(e[1])):e[1],headers:e[2],config:t}}function o(e,t,n,o){o.baseURL&&o.url.substr(0,o.baseURL.length)===o.baseURL&&(o.url=o.url.slice(o.baseURL?o.baseURL.length:0)),o.adapter=null;var s=i.findHandler(e.handlers,o.method,o.url,o.data,o.params,o.headers);if(s)if(i.purgeIfReplyOnce(e,s),2===s.length)o.adapter=e.originalAdapter,e.axiosInstance.request(o).then(t,n);else if(s[3]instanceof Function){var u=s[3](o);u.then instanceof Function?u.then(function(s){i.settle(t,n,r(s,o),e.delayResponse)},function(t){e.delayResponse>0?setTimeout(function(){n(t)},e.delayResponse):n(t)}):i.settle(t,n,r(u,o),e.delayResponse)}else i.settle(t,n,r(s.slice(3),o),e.delayResponse);else i.settle(t,n,{status:404,config:o},e.delayResponse)}var i=n(2);e.exports=o},function(e,t,n){"use strict";function r(e,t){return g(e,t,{strict:!0})}function o(e,t){for(var n=e.length,r=0;r<n;r++){var o=e[r];if(t(o))return o}}function i(e,t,n,r,i,c){return o(e[t.toLowerCase()],function(e){return"string"==typeof e[0]?s(n,e[0])&&a(t,r,i,e[1])&&u(c,e[2]):e[0]instanceof RegExp?e[0].test(n)&&a(t,r,i,e[1])&&u(c,e[2]):void 0})}function s(e,t){return("/"===e[0]?e.substr(1):e)===("/"===t[0]?t.substr(1):t)}function u(e,t){return void 0===t||r(e,t)}function a(e,t,n,r){if(["delete","get","head","options"].indexOf(e.toLowerCase())>=0)return c(n,r?r.params:void 0);return f(t,r)}function c(e,t){return void 0===t||r(e,t)}function f(e,t){if(void 0===t)return!0;var n;try{n=JSON.parse(e)}catch(e){}return n?r(n,t):r(e,t)}function l(e,t){var n=e.replyOnceHandlers.indexOf(t);n>-1&&(e.replyOnceHandlers.splice(n,1),Object.keys(e.handlers).forEach(function(r){(n=e.handlers[r].indexOf(t))>-1&&e.handlers[r].splice(n,1)}))}function p(e,t,n,r){return r>0?void setTimeout(function(){p(e,t,n)},r):n.config&&n.config.validateStatus?void(n.config.validateStatus(n.status)?e(n):t(d("Request failed with status code "+n.status,n.config,n))):void(n.status>=200&&n.status<300?e(n):t(n))}function d(e,t,n){if(!v)return n;var r=new Error(e);return r.config=t,r.response=n,r}function h(e){return null!==e&&void 0!==e&&"[object Object]"===e.toString()}var y=n(3),g=n(4),v=!!y.create().defaults.headers;e.exports={find:o,findHandler:i,isSimpleObject:h,purgeIfReplyOnce:l,settle:p}},function(t,n){t.exports=e},function(e,t,n){function r(e){return null===e||void 0===e}function o(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&!(e.length>0&&"number"!=typeof e[0]))}function i(e,t,n){var i,f;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(a(e))return!!a(t)&&(e=s.call(e),t=s.call(t),c(e,t,n));if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}try{var l=u(e),p=u(t)}catch(e){return!1}if(l.length!=p.length)return!1;for(l.sort(),p.sort(),i=l.length-1;i>=0;i--)if(l[i]!=p[i])return!1;for(i=l.length-1;i>=0;i--)if(f=l[i],!c(e[f],t[f],n))return!1;return typeof e==typeof t}var s=Array.prototype.slice,u=n(5),a=n(6),c=e.exports=function(e,t,n){return n||(n={}),e===t||(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?n.strict?e===t:e==t:i(e,t,n))}},function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}t=e.exports="function"==typeof Object.keys?Object.keys:n,t.shim=n},function(e,t){function n(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();t=e.exports=o?n:r,t.supported=n,t.unsupported=r}])}); |
{ | ||
"name": "axios-mock-adapter", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "Axios adapter that allows to easily mock requests", | ||
@@ -48,3 +48,3 @@ "main": "src/index.js", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^4.0.1", | ||
"mocha": "^5.0.0", | ||
"rimraf": "^2.6.1", | ||
@@ -51,0 +51,0 @@ "webpack": "^3.3.0" |
@@ -112,2 +112,3 @@ 'use strict'; | ||
module.exports = module.exports.default = MockAdapter; | ||
module.exports = MockAdapter; | ||
module.exports.default = MockAdapter; |
@@ -45,2 +45,2 @@ import { AxiosAdapter, AxiosInstance, AxiosRequestConfig } from "axios"; | ||
export = MockAdapter; | ||
export default MockAdapter; |
import axios from "axios"; | ||
import MockAdapter = require("axios-mock-adapter"); | ||
import MockAdapter from "axios-mock-adapter"; | ||
@@ -4,0 +4,0 @@ const instance = axios.create(); |
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
43708
878