UNPKG

@haxtheweb/haxcms-nodejs

Version:

HAXcms single and multisite nodejs server, api, and administration

100 lines 90.1 kB
var root,factory;root=this,factory=function(){var samsam,formatio,lolex,define;(function(){function define(t,n,r){"samsam"==t?samsam=n():"function"==typeof n&&0===t.length?lolex=n():"function"==typeof r&&(formatio=r(samsam))}define.amd={},("function"==typeof define&&define.amd&&function(t){define("samsam",t)}||"object"==typeof module&&function(t){module.exports=t()}||function(t){this.samsam=t()})((function(){var t,n=Object.prototype,r="undefined"!=typeof document&&document.createElement("div");function isNaN(t){return"number"==typeof t&&t!=t}function getClass(t){return n.toString.call(t).split(/[ \]]/)[1]}function isArguments(t){if("Arguments"===getClass(t))return!0;if("object"!=typeof t||"number"!=typeof t.length||"Array"===getClass(t))return!1;if("function"==typeof t.callee)return!0;try{t[t.length]=6,delete t[t.length]}catch(t){return!0}return!1}function isElement(t){if(!t||1!==t.nodeType||!r)return!1;try{t.appendChild(r),t.removeChild(r)}catch(t){return!1}return!0}function keys(t){var r,o=[];for(r in t)n.hasOwnProperty.call(t,r)&&o.push(r);return o}function isDate(t){return"function"==typeof t.getTime&&t.getTime()==t.valueOf()}function isNegZero(t){return 0===t&&1/t==-1/0}function identical(t,n){if(t===n||isNaN(t)&&isNaN(n))return 0!==t||isNegZero(t)===isNegZero(n)}function arrayContains(n,r){if(0===r.length)return!0;var o,i,a,c;for(o=0,i=n.length;o<i;++o)if(t(n[o],r[0])){for(a=0,c=r.length;a<c;++a)if(!t(n[o+a],r[a]))return!1;return!0}return!1}return{isArguments,isElement,isDate,isNegZero,identical,deepEqual:function deepEqualCyclic(t,r){var o=[],i=[],a=[],c=[],l={};function isObject(t){return!("object"!=typeof t||null===t||t instanceof Boolean||t instanceof Date||t instanceof Number||t instanceof RegExp||t instanceof String)}function getIndex(t,n){var r;for(r=0;r<t.length;r++)if(t[r]===n)return r;return-1}return function deepEqual(t,r,u,f){var d=typeof t,h=typeof r;if(t===r||isNaN(t)||isNaN(r)||null==t||null==r||"object"!==d||"object"!==h)return identical(t,r);if(isElement(t)||isElement(r))return!1;var m=isDate(t),y=isDate(r);if((m||y)&&(!m||!y||t.getTime()!==r.getTime()))return!1;if(t instanceof RegExp&&r instanceof RegExp&&t.toString()!==r.toString())return!1;var g,v,b,w,k,x,A,C,E,T,q,R=getClass(t),D=getClass(r),S=keys(t),O=keys(r);if(isArguments(t)||isArguments(r)){if(t.length!==r.length)return!1}else if(d!==h||R!==D||S.length!==O.length)return!1;for(v=0,b=S.length;v<b;v++){if(g=S[v],!n.hasOwnProperty.call(r,g))return!1;if(w=t[g],k=r[g],x=isObject(w),A=isObject(k),C=x?getIndex(o,w):-1,E=A?getIndex(i,k):-1,T=-1!==C?a[C]:u+"["+JSON.stringify(g)+"]",q=-1!==E?c[E]:f+"["+JSON.stringify(g)+"]",l[T+q])return!0;if(-1===C&&x&&(o.push(w),a.push(T)),-1===E&&A&&(i.push(k),c.push(q)),x&&A&&(l[T+q]=!0),!deepEqual(w,k,T,q))return!1}return!0}(t,r,"$1","$2")},match:t=function match(t,n){if(n&&"function"==typeof n.test)return n.test(t);if("function"==typeof n)return!0===n(t);if("string"==typeof n)return n=n.toLowerCase(),("string"==typeof t||!!t)&&String(t).toLowerCase().indexOf(n)>=0;if("number"==typeof n)return n===t;if("boolean"==typeof n)return n===t;if(void 0===n)return void 0===t;if(null===n)return null===t;if("Array"===getClass(t)&&"Array"===getClass(n))return arrayContains(t,n);if(n&&"object"==typeof n){if(n===t)return!0;var r;for(r in n){var o=t[r];if(void 0===o&&"function"==typeof t.getAttribute&&(o=t.getAttribute(r)),null===n[r]||void 0===n[r]){if(o!==n[r])return!1}else if(void 0===o||!match(o,n[r]))return!1}return!0}throw new Error("Matcher was not a string, a number, a function, a boolean or an object")},keys}})),("function"==typeof define&&define.amd&&function(t){define("formatio",["samsam"],t)}||"object"==typeof module&&function(t){module.exports=t(require("samsam"))}||function(t){this.formatio=t(this.samsam)})((function(t){var n={excludeConstructors:["Object",/^.$/],quoteStrings:!0,limitChildrenCount:0},r=(Object.prototype.hasOwnProperty,[]);function functionName(t){if(!t)return"";if(t.displayName)return t.displayName;if(t.name)return t.name;var n=t.toString().match(/function\s+([^\(]+)/m);return n&&n[1]||""}function constructorName(t,r){var o,i,a=functionName(r&&r.constructor),c=t.excludeConstructors||n.excludeConstructors||[];for(o=0,i=c.length;o<i;++o){if("string"==typeof c[o]&&c[o]===a)return"";if(c[o].test&&c[o].test(a))return""}return a}function isCircular(t,n){if("object"!=typeof t)return!1;var r,o;for(r=0,o=n.length;r<o;++r)if(n[r]===t)return!0;return!1}function ascii(n,o,i,a){if("string"==typeof o){var c=n.quoteStrings;return i||"boolean"!=typeof c||c?'"'+o+'"':o}if("function"==typeof o&&!(o instanceof RegExp))return ascii.func(o);if(isCircular(o,i=i||[]))return"[Circular]";if("[object Array]"===Object.prototype.toString.call(o))return ascii.array.call(n,o,i);if(!o)return String(1/o==-1/0?"-0":o);if(t.isElement(o))return ascii.element(o);if("function"==typeof o.toString&&o.toString!==Object.prototype.toString)return o.toString();var l,u;for(l=0,u=r.length;l<u;l++)if(o===r[l].object)return r[l].value;return ascii.object.call(n,o,i,a)}function Formatio(t){for(var n in t)this[n]=t[n]}return"undefined"!=typeof global&&r.push({object:global,value:"[object global]"}),"undefined"!=typeof document&&r.push({object:document,value:"[object HTMLDocument]"}),"undefined"!=typeof window&&r.push({object:window,value:"[object Window]"}),ascii.func=function(t){return"function "+functionName(t)+"() {}"},ascii.array=function(t,n){(n=n||[]).push(t);var r,o,i=[];for(o=this.limitChildrenCount>0?Math.min(this.limitChildrenCount,t.length):t.length,r=0;r<o;++r)i.push(ascii(this,t[r],n));return o<t.length&&i.push("[... "+(t.length-o)+" more elements]"),"["+i.join(", ")+"]"},ascii.object=function(n,r,o){(r=r||[]).push(n),o=o||0;var i,a,c,l,u,f,d=[],h=t.keys(n).sort(),m=3;for(f=this.limitChildrenCount>0?Math.min(this.limitChildrenCount,h.length):h.length,l=0;l<f;++l)a=isCircular(c=n[i=h[l]],r)?"[Circular]":ascii(this,c,r,o+2),m+=(a=(/\s/.test(i)?'"'+i+'"':i)+": "+a).length,d.push(a);var y=constructorName(this,n),g=y?"["+y+"] ":"",v="";for(l=0,u=o;l<u;++l)v+=" ";return f<h.length&&d.push("[... "+(h.length-f)+" more elements]"),m+o>80?g+"{\n "+v+d.join(",\n "+v)+"\n"+v+"}":g+"{ "+d.join(", ")+" }"},ascii.element=function(t){var n,r,o,i,a,c=t.tagName.toLowerCase(),l=t.attributes,u=[];for(o=0,i=l.length;o<i;++o)r=(n=l.item(o)).nodeName.toLowerCase().replace("html:",""),a=n.nodeValue,"contenteditable"===r&&"inherit"===a||a&&u.push(r+'="'+a+'"');var f="<"+c+(u.length>0?" ":""),d=t.innerHTML;return d.length>20&&(d=d.substr(0,20)+"[...]"),(f+u.join(" ")+">"+d+"</"+c+">").replace(/ contentEditable="inherit"/,"")},Formatio.prototype={functionName,configure:function(t){return new Formatio(t)},constructorName:function(t){return constructorName(this,t)},ascii:function(t,n,r){return ascii(this,t,n,r)}},Formatio.prototype})),function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.lolex=t()}}((function(){var define,module,exports;return function e(t,n,r){function s(i,a){if(!n[i]){if(!t[i]){var c="function"==typeof require&&require;if(!a&&c)return c(i,!0);if(o)return o(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[i]={exports:{}};t[i][0].call(u.exports,(function(n){var r=t[i][1][n];return s(r||n)}),u,u.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)s(r[i]);return s}({1:[function(require,module,exports){(function(global){ /** * @author Christian Johansen (christian@cjohansen.no) and contributors * @license BSD * * Copyright (c) 2010-2014 Christian Johansen */ (function(global){var glbl=global;global.setTimeout=glbl.setTimeout,global.clearTimeout=glbl.clearTimeout,global.setInterval=glbl.setInterval,global.clearInterval=glbl.clearInterval,global.Date=glbl.Date,"setImmediate"in global&&(global.setImmediate=glbl.setImmediate,global.clearImmediate=glbl.clearImmediate);var NOOP=function(){},timeoutResult=setTimeout(NOOP,0),addTimerReturnsObject="object"==typeof timeoutResult;clearTimeout(timeoutResult);var NativeDate=Date,uniqueTimerId=1;function parseTime(t){if(!t)return 0;var n,r=t.split(":"),o=r.length,i=o,a=0;if(o>3||!/^(\d\d:){0,2}\d\d?$/.test(t))throw new Error("tick only understands numbers and 'h:m:s'");for(;i--;){if((n=parseInt(r[i],10))>=60)throw new Error("Invalid time "+t);a+=n*Math.pow(60,o-i-1)}return 1e3*a}function getEpoch(t){if(!t)return 0;if("function"==typeof t.getTime)return t.getTime();if("number"==typeof t)return t;throw new TypeError("now should be milliseconds since UNIX epoch")}function inRange(t,n,r){return r&&r.callAt>=t&&r.callAt<=n}function mirrorDateProperties(t,n){var r;for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);return n.now?t.now=function now(){return t.clock.now}:delete t.now,n.toSource?t.toSource=function toSource(){return n.toSource()}:delete t.toSource,t.toString=function toString(){return n.toString()},t.prototype=n.prototype,t.parse=n.parse,t.UTC=n.UTC,t.prototype.toUTCString=n.prototype.toUTCString,t}function createDate(){return mirrorDateProperties((function ClockDate(t,n,r,o,i,a,c){switch(arguments.length){case 0:return new NativeDate(ClockDate.clock.now);case 1:return new NativeDate(t);case 2:return new NativeDate(t,n);case 3:return new NativeDate(t,n,r);case 4:return new NativeDate(t,n,r,o);case 5:return new NativeDate(t,n,r,o,i);case 6:return new NativeDate(t,n,r,o,i,a);default:return new NativeDate(t,n,r,o,i,a,c)}}),NativeDate)}function addTimer(t,n){if(void 0===n.func)throw new Error("Callback must be provided to timer calls");return t.timers||(t.timers={}),n.id=uniqueTimerId++,n.createdAt=t.now,n.callAt=t.now+(n.delay||(t.duringTick?1:0)),t.timers[n.id]=n,addTimerReturnsObject?{id:n.id,ref:NOOP,unref:NOOP}:n.id}function compareTimers(t,n){return t.callAt<n.callAt?-1:t.callAt>n.callAt?1:t.immediate&&!n.immediate?-1:!t.immediate&&n.immediate?1:t.createdAt<n.createdAt?-1:t.createdAt>n.createdAt?1:t.id<n.id?-1:t.id>n.id?1:void 0}function firstTimerInRange(t,n,r){var o,i=t.timers,a=null;for(o in i)i.hasOwnProperty(o)&&(!inRange(n,r,i[o])||a&&1!==compareTimers(a,i[o])||(a=i[o]));return a}function callTimer(clock,timer){var exception;"number"==typeof timer.interval?clock.timers[timer.id].callAt+=timer.interval:delete clock.timers[timer.id];try{"function"==typeof timer.func?timer.func.apply(null,timer.args):eval(timer.func)}catch(t){exception=t}if(clock.timers[timer.id]){if(exception)throw exception}else if(exception)throw exception}function timerType(t){return t.immediate?"Immediate":void 0!==t.interval?"Interval":"Timeout"}function clearTimer(t,n,r){if(n&&(t.timers||(t.timers=[]),"object"==typeof n&&(n=n.id),t.timers.hasOwnProperty(n))){var o=t.timers[n];if(timerType(o)!==r)throw new Error("Cannot clear timer: timer created with set"+r+"() but cleared with clear"+timerType(o)+"()");delete t.timers[n]}}function uninstall(t,n){var r,o,i;for(o=0,i=t.methods.length;o<i;o++)if(n[r=t.methods[o]].hadOwnProperty)n[r]=t["_"+r];else try{delete n[r]}catch(t){}t.methods=[]}function hijackMethod(t,n,r){var o;if(r[n].hadOwnProperty=Object.prototype.hasOwnProperty.call(t,n),r["_"+n]=t[n],"Date"===n){var i=mirrorDateProperties(r[n],t[n]);t[n]=i}else for(o in t[n]=function(){return r[n].apply(r,arguments)},r[n])r[n].hasOwnProperty(o)&&(t[n][o]=r[n][o]);t[n].clock=r}var timers={setTimeout,clearTimeout,setImmediate:global.setImmediate,clearImmediate:global.clearImmediate,setInterval,clearInterval,Date},keys=Object.keys||function(t){var n,r=[];for(n in t)t.hasOwnProperty(n)&&r.push(n);return r};function createClock(t){var n={now:getEpoch(t),timeouts:{},Date:createDate()};return n.Date.clock=n,n.setTimeout=function setTimeout(t,r){return addTimer(n,{func:t,args:Array.prototype.slice.call(arguments,2),delay:r})},n.clearTimeout=function clearTimeout(t){return clearTimer(n,t,"Timeout")},n.setInterval=function setInterval(t,r){return addTimer(n,{func:t,args:Array.prototype.slice.call(arguments,2),delay:r,interval:r})},n.clearInterval=function clearInterval(t){return clearTimer(n,t,"Interval")},n.setImmediate=function setImmediate(t){return addTimer(n,{func:t,args:Array.prototype.slice.call(arguments,1),immediate:!0})},n.clearImmediate=function clearImmediate(t){return clearTimer(n,t,"Immediate")},n.tick=function tick(t){t="number"==typeof t?t:parseTime(t);var r,o,i=n.now,a=n.now+t,c=n.now,l=firstTimerInRange(n,i,a);for(n.duringTick=!0;l&&i<=a;){if(n.timers[l.id]){i=n.now=l.callAt;try{r=n.now,callTimer(n,l),r!==n.now&&(i+=n.now-r,a+=n.now-r,c+=n.now-r)}catch(t){o=o||t}}l=firstTimerInRange(n,c,a),c=i}if(n.duringTick=!1,n.now=a,o)throw o;return n.now},n.reset=function reset(){n.timers={}},n.setSystemTime=function setSystemTime(t){var r=getEpoch(t),o=r-n.now;for(var i in n.now=r,n.timers)if(n.timers.hasOwnProperty(i)){var a=n.timers[i];a.createdAt+=o,a.callAt+=o}},n}exports.timers=timers,exports.createClock=createClock,exports.install=function install(t,n,r){var o,i;"number"==typeof t&&(r=n,n=t,t=null),t||(t=global);var a=createClock(n);for(a.uninstall=function(){uninstall(a,t)},a.methods=r||[],0===a.methods.length&&(a.methods=keys(timers)),o=0,i=a.methods.length;o<i;o++)hijackMethod(t,a.methods[o],a);return a}})(global||this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)}))})(); /** * Sinon core utilities. For internal use only. * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */ var sinon=function(){var t,n="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(n,r,o){t=o.exports=n("./sinon/util/core"),n("./sinon/extend"),n("./sinon/walk"),n("./sinon/typeOf"),n("./sinon/times_in_words"),n("./sinon/spy"),n("./sinon/call"),n("./sinon/behavior"),n("./sinon/stub"),n("./sinon/mock"),n("./sinon/collection"),n("./sinon/assert"),n("./sinon/sandbox"),n("./sinon/test"),n("./sinon/test_case"),n("./sinon/match"),n("./sinon/format"),n("./sinon/log_error")}return"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?(loadDependencies(require,module.exports,module),t=module.exports):t={},t}(); /** * Sinon core utilities. For internal use only. * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */return function(t){var n="undefined"!=typeof document&&document.createElement("div"),r=Object.prototype.hasOwnProperty;function isElement(t){return n&&t&&1===t.nodeType&&function isDOMNode(t){var r=!1;try{t.appendChild(n),r=n.parentNode===t}catch(t){return!1}finally{try{t.removeChild(n)}catch(t){}}return r}(t)}function isReallyNaN(t){return"number"==typeof t&&isNaN(t)}function mirrorProperties(t,n){for(var o in n)r.call(t,o)||(t[o]=n[o])}function isRestorable(t){return"function"==typeof t&&"function"==typeof t.restore&&t.restore.sinon}var o="keys"in Object;function makeApi(t){return t.wrapMethod=function wrapMethod(n,i,a){if(!n)throw new TypeError("Should wrap property of object");if("function"!=typeof a&&"object"!=typeof a)throw new TypeError("Method wrapper should be a function or a property descriptor");function checkWrappedMethod(t){var n;if(function isFunction(t){return"function"==typeof t||!!(t&&t.constructor&&t.call&&t.apply)}(t)){if(t.restore&&t.restore.sinon)n=new TypeError("Attempted to wrap "+i+" which is already wrapped");else if(t.calledBefore){var r=t.returns?"stubbed":"spied on";n=new TypeError("Attempted to wrap "+i+" which is already "+r)}}else n=new TypeError("Attempted to wrap "+typeof t+" property "+i+" as function");if(n)throw t&&t.stackTrace&&(n.stack+="\n--------------\n"+t.stackTrace),n}var c,l,u,f=n.hasOwnProperty?n.hasOwnProperty(i):r.call(n,i);if(o){var d="function"==typeof a?{value:a}:a,h=t.getPropertyDescriptor(n,i);if(h?h.restore&&h.restore.sinon&&(c=new TypeError("Attempted to wrap "+i+" which is already wrapped")):c=new TypeError("Attempted to wrap "+typeof l+" property "+i+" as function"),c)throw h&&h.stackTrace&&(c.stack+="\n--------------\n"+h.stackTrace),c;var m=t.objectKeys(d);for(u=0;u<m.length;u++)checkWrappedMethod(l=h[m[u]]);for(mirrorProperties(d,h),u=0;u<m.length;u++)mirrorProperties(d[m[u]],h[m[u]]);Object.defineProperty(n,i,d)}else checkWrappedMethod(l=n[i]),n[i]=a,a.displayName=i;return a.displayName=i,a.stackTrace=new Error("Stack Trace for original").stack,a.restore=function(){if(f)o&&Object.defineProperty(n,i,h);else try{delete n[i]}catch(t){}n[i]===a&&(n[i]=l)},a.restore.sinon=!0,o||mirrorProperties(a,l),a},t.create=function create(t){var F=function(){};return F.prototype=t,new F},t.deepEqual=function deepEqual(n,r){if(t.match&&t.match.isMatcher(n))return n.test(r);if("object"!=typeof n||"object"!=typeof r)return isReallyNaN(n)&&isReallyNaN(r)||n===r;if(isElement(n)||isElement(r))return n===r;if(n===r)return!0;if(null===n&&null!==r||null!==n&&null===r)return!1;if(n instanceof RegExp&&r instanceof RegExp)return n.source===r.source&&n.global===r.global&&n.ignoreCase===r.ignoreCase&&n.multiline===r.multiline;var o,i=Object.prototype.toString.call(n);if(i!==Object.prototype.toString.call(r))return!1;if("[object Date]"===i)return n.valueOf()===r.valueOf();var a=0,c=0;if("[object Array]"===i&&n.length!==r.length)return!1;for(o in n)if(n.hasOwnProperty(o)){if(a+=1,!(o in r))return!1;if(!deepEqual(n[o],r[o]))return!1}for(o in r)r.hasOwnProperty(o)&&(c+=1);return a===c},t.functionName=function functionName(t){var n=t.displayName||t.name;if(!n){var r=t.toString().match(/function ([^\s\(]+)/);n=r&&r[1]}return n},t.functionToString=function toString(){if(this.getCall&&this.callCount)for(var t,n,r=this.callCount;r--;)for(n in t=this.getCall(r).thisValue)if(t[n]===this)return n;return this.displayName||"sinon fake"},t.objectKeys=function objectKeys(t){if(t!==Object(t))throw new TypeError("sinon.objectKeys called on a non-object");var n,o=[];for(n in t)r.call(t,n)&&o.push(n);return o},t.getPropertyDescriptor=function getPropertyDescriptor(t,n){for(var r,o=t;o&&!(r=Object.getOwnPropertyDescriptor(o,n));)o=Object.getPrototypeOf(o);return r},t.getConfig=function(n){var r={};n=n||{};var o=t.defaultConfig;for(var i in o)o.hasOwnProperty(i)&&(r[i]=n.hasOwnProperty(i)?n[i]:o[i]);return r},t.defaultConfig={injectIntoThis:!0,injectInto:null,properties:["spy","stub","mock","clock","server","requests"],useFakeTimers:!0,useFakeServer:!0},t.timesInWords=function timesInWords(t){return(1===t?"once":2===t&&"twice")||3===t&&"thrice"||(t||0)+" times"},t.calledInOrder=function(t){for(var n=1,r=t.length;n<r;n++)if(!t[n-1].calledBefore(t[n])||!t[n].called)return!1;return!0},t.orderByFirstCall=function(t){return t.sort((function(t,n){var r=t.getCall(0),o=n.getCall(0);return(r&&r.callId||-1)<(o&&o.callId||-1)?-1:1}))},t.createStubInstance=function(n){if("function"!=typeof n)throw new TypeError("The constructor should be a function.");return t.stub(t.create(n.prototype))},t.restore=function(t){if(null!==t&&"object"==typeof t)for(var n in t)isRestorable(t[n])&&t[n].restore();else isRestorable(t)&&t.restore()},t}var i="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(t,n){makeApi(n)}"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):i?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon),function(t){function makeApi(t){var n=function(){var t={constructor:function(){return"0"},toString:function(){return"1"},valueOf:function(){return"2"},toLocaleString:function(){return"3"},prototype:function(){return"4"},isPrototypeOf:function(){return"5"},propertyIsEnumerable:function(){return"6"},hasOwnProperty:function(){return"7"},length:function(){return"8"},unique:function(){return"9"}},n=[];for(var r in t)t.hasOwnProperty(r)&&n.push(t[r]());return"0123456789"!==n.join("")}();return t.extend=function extend(t){var r,o,i,a=Array.prototype.slice.call(arguments,1);for(o=0;o<a.length;o++){for(i in r=a[o])r.hasOwnProperty(i)&&(t[i]=r[i]);n&&r.hasOwnProperty("toString")&&r.toString!==t.toString&&(t.toString=r.toString)}return t},t.extend}function loadDependencies(t,n,r){var o=t("./util/core");r.exports=makeApi(o)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon),function(t){function makeApi(t){return t.timesInWords=function timesInWords(t){switch(t){case 1:return"once";case 2:return"twice";case 3:return"thrice";default:return(t||0)+" times"}},t.timesInWords}function loadDependencies(t,n,r){var o=t("./util/core");r.exports=makeApi(o)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Format functions * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2014 Christian Johansen */ function(t){function makeApi(t){return t.typeOf=function typeOf(t){if(null===t)return"null";if(void 0===t)return"undefined";var n=Object.prototype.toString.call(t);return n.substring(8,n.length-1).toLowerCase()},t.typeOf}function loadDependencies(t,n,r){var o=t("./util/core");r.exports=makeApi(o)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Match functions * * @author Maximilian Antoni (mail@maxantoni.de) * @license BSD * * Copyright (c) 2012 Maximilian Antoni */ function(t){function makeApi(t){function assertType(n,r,o){var i=t.typeOf(n);if(i!==r)throw new TypeError("Expected type of "+o+" to be "+r+", but was "+i)}var n={toString:function(){return this.message}};function isMatcher(t){return n.isPrototypeOf(t)}function matchObject(n,r){if(null==r)return!1;for(var o in n)if(n.hasOwnProperty(o)){var i=n[o],a=r[o];if(isMatcher(i)){if(!i.test(a))return!1}else if("object"===t.typeOf(i)){if(!matchObject(i,a))return!1}else if(!t.deepEqual(i,a))return!1}return!0}function match(r,o){var i=t.create(n);switch(t.typeOf(r)){case"object":if("function"==typeof r.test)return i.test=function(t){return!0===r.test(t)},i.message="match("+t.functionName(r.test)+")",i;var a=[];for(var c in r)r.hasOwnProperty(c)&&a.push(c+": "+r[c]);i.test=function(t){return matchObject(r,t)},i.message="match("+a.join(", ")+")";break;case"number":i.test=function(t){return r==t};break;case"string":i.test=function(t){return"string"==typeof t&&-1!==t.indexOf(r)},i.message='match("'+r+'")';break;case"regexp":i.test=function(t){return"string"==typeof t&&r.test(t)};break;case"function":i.test=r,i.message=o||"match("+t.functionName(r)+")";break;default:i.test=function(n){return t.deepEqual(r,n)}}return i.message||(i.message="match("+r+")"),i}function createPropertyMatcher(n,r){return function(o,i){assertType(o,"string","property");var a=1===arguments.length,c=r+'("'+o+'"';return a||(c+=", "+i),match((function(r){return!(null==r||!n(r,o))&&(a||t.deepEqual(i,r[o]))}),c+=")")}}return n.or=function(r){if(!arguments.length)throw new TypeError("Matcher expected");isMatcher(r)||(r=match(r));var o=this,i=t.create(n);return i.test=function(t){return o.test(t)||r.test(t)},i.message=o.message+".or("+r.message+")",i},n.and=function(r){if(!arguments.length)throw new TypeError("Matcher expected");isMatcher(r)||(r=match(r));var o=this,i=t.create(n);return i.test=function(t){return o.test(t)&&r.test(t)},i.message=o.message+".and("+r.message+")",i},match.isMatcher=isMatcher,match.any=match((function(){return!0}),"any"),match.defined=match((function(t){return null!=t}),"defined"),match.truthy=match((function(t){return!!t}),"truthy"),match.falsy=match((function(t){return!t}),"falsy"),match.same=function(t){return match((function(n){return t===n}),"same("+t+")")},match.typeOf=function(n){return assertType(n,"string","type"),match((function(r){return t.typeOf(r)===n}),'typeOf("'+n+'")')},match.instanceOf=function(n){return assertType(n,"function","type"),match((function(t){return t instanceof n}),"instanceOf("+t.functionName(n)+")")},match.has=createPropertyMatcher((function(t,n){return"object"==typeof t?n in t:void 0!==t[n]}),"has"),match.hasOwn=createPropertyMatcher((function(t,n){return t.hasOwnProperty(n)}),"hasOwn"),match.bool=match.typeOf("boolean"),match.number=match.typeOf("number"),match.string=match.typeOf("string"),match.object=match.typeOf("object"),match.func=match.typeOf("function"),match.array=match.typeOf("array"),match.regexp=match.typeOf("regexp"),match.date=match.typeOf("date"),t.match=match,match}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(t,n,r){var o=t("./util/core");t("./typeOf"),r.exports=makeApi(o)}"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Format functions * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2014 Christian Johansen */ function(t,n){function makeApi(t){function valueFormatter(t){return""+t}var r,o="undefined"!=typeof module&&module.exports&&"function"==typeof require;if(o)try{n=require("formatio")}catch(t){}return r=n?function getFormatioFormatter(){var t=n.configure({quoteStrings:!1,limitChildrenCount:250});return function format(){return t.ascii.apply(t,arguments)}}():o?function getNodeFormatter(){try{var t=require("util")}catch(t){}return t?function format(n){return"object"==typeof n&&n.toString===Object.prototype.toString?t.inspect(n):n}:valueFormatter}():valueFormatter,t.format=r,t.format}function loadDependencies(t,n,r){var o=t("./util/core");r.exports=makeApi(o)}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):r?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon,"object"==typeof formatio&&formatio), /** * Spy calls * * @author Christian Johansen (christian@cjohansen.no) * @author Maximilian Antoni (mail@maxantoni.de) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen * Copyright (c) 2013 Maximilian Antoni */ function(t){var n=Array.prototype.slice;function makeApi(t){function throwYieldError(r,o,i){var a=t.functionName(r)+o;throw i.length&&(a+=" Received ["+n.call(i).join(", ")+"]"),new Error(a)}var r={calledOn:function calledOn(n){return t.match&&t.match.isMatcher(n)?n.test(this.thisValue):this.thisValue===n},calledWith:function calledWith(){var n=arguments.length;if(n>this.args.length)return!1;for(var r=0;r<n;r+=1)if(!t.deepEqual(arguments[r],this.args[r]))return!1;return!0},calledWithMatch:function calledWithMatch(){var n=arguments.length;if(n>this.args.length)return!1;for(var r=0;r<n;r+=1){var o=this.args[r],i=arguments[r];if(!t.match||!t.match(i).test(o))return!1}return!0},calledWithExactly:function calledWithExactly(){return arguments.length===this.args.length&&this.calledWith.apply(this,arguments)},notCalledWith:function notCalledWith(){return!this.calledWith.apply(this,arguments)},notCalledWithMatch:function notCalledWithMatch(){return!this.calledWithMatch.apply(this,arguments)},returned:function returned(n){return t.deepEqual(n,this.returnValue)},threw:function threw(t){return void 0!==t&&this.exception?this.exception===t||this.exception.name===t:!!this.exception},calledWithNew:function calledWithNew(){return this.proxy.prototype&&this.thisValue instanceof this.proxy},calledBefore:function(t){return this.callId<t.callId},calledAfter:function(t){return this.callId>t.callId},callArg:function(t){this.args[t]()},callArgOn:function(t,n){this.args[t].apply(n)},callArgWith:function(t){this.callArgOnWith.apply(this,[t,null].concat(n.call(arguments,1)))},callArgOnWith:function(t,r){var o=n.call(arguments,2);this.args[t].apply(r,o)},yield:function(){this.yieldOn.apply(this,[null].concat(n.call(arguments,0)))},yieldOn:function(t){for(var r=this.args,o=0,i=r.length;o<i;++o)if("function"==typeof r[o])return void r[o].apply(t,n.call(arguments,1));throwYieldError(this.proxy," cannot yield since no callback was passed.",r)},yieldTo:function(t){this.yieldToOn.apply(this,[t,null].concat(n.call(arguments,1)))},yieldToOn:function(t,r){for(var o=this.args,i=0,a=o.length;i<a;++i)if(o[i]&&"function"==typeof o[i][t])return void o[i][t].apply(r,n.call(arguments,2));throwYieldError(this.proxy," cannot yield to '"+t+"' since no callback was passed.",o)},getStackFrames:function(){return this.stack&&this.stack.split("\n").slice(3)},toString:function(){for(var n=this.proxy.toString()+"(",r=[],o=0,i=this.args.length;o<i;++o)r.push(t.format(this.args[o]));return n=n+r.join(", ")+")",void 0!==this.returnValue&&(n+=" => "+t.format(this.returnValue)),this.exception&&(n+=" !"+this.exception.name,this.exception.message&&(n+="("+this.exception.message+")")),this.stack&&(n+=this.getStackFrames()[0].replace(/^\s*(?:at\s+|@)?/," at ")),n}};function createSpyCall(n,o,i,a,c,l,u){if("number"!=typeof l)throw new TypeError("Call id is not a number");var f=t.create(r);return f.proxy=n,f.thisValue=o,f.args=i,f.returnValue=a,f.exception=c,f.callId=l,f.stack=u,f}return r.invokeCallback=r.yield,createSpyCall.toString=r.toString,t.spyCall=createSpyCall,createSpyCall}var r="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(t,n,r){var o=t("./util/core");t("./match"),t("./format"),r.exports=makeApi(o)}"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):r?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Spy functions * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */ function(sinonGlobal){function makeApi(sinon){var push=Array.prototype.push,slice=Array.prototype.slice,callId=0;function spy(t,n,r){if(!n&&"function"==typeof t)return spy.create(t);if(!t&&!n)return spy.create((function(){}));if(r){for(var o=sinon.getPropertyDescriptor(t,n),i=0;i<r.length;i++)o[r[i]]=spy.create(o[r[i]]);return sinon.wrapMethod(t,n,o)}return sinon.wrapMethod(t,n,spy.create(t[n]))}function matchingFake(t,n,r){if(t)for(var o=0,i=t.length;o<i;o++)if(t[o].matches(n,r))return t[o]}function incrementCallCount(){this.called=!0,this.callCount+=1,this.notCalled=!1,this.calledOnce=1===this.callCount,this.calledTwice=2===this.callCount,this.calledThrice=3===this.callCount}function createCallProperties(){this.firstCall=this.getCall(0),this.secondCall=this.getCall(1),this.thirdCall=this.getCall(2),this.lastCall=this.getCall(this.callCount-1)}var vars="a,b,c,d,e,f,g,h,i,j,k,l";function createProxy(func,proxyLength){var p;return proxyLength?eval("p = (function proxy("+vars.substring(0,2*proxyLength-1)+") { return p.invoke(func, this, slice.call(arguments)); });"):p=function proxy(){return p.invoke(func,this,slice.call(arguments))},p.isSinonProxy=!0,p}var uuid=0,spyApi={reset:function(){if(this.invoking){var t=new Error("Cannot reset Sinon function while invoking it. Move the call to .reset outside of the callback.");throw t.name="InvalidResetException",t}if(this.called=!1,this.notCalled=!0,this.calledOnce=!1,this.calledTwice=!1,this.calledThrice=!1,this.callCount=0,this.firstCall=null,this.secondCall=null,this.thirdCall=null,this.lastCall=null,this.args=[],this.returnValues=[],this.thisValues=[],this.exceptions=[],this.callIds=[],this.stacks=[],this.fakes)for(var n=0;n<this.fakes.length;n++)this.fakes[n].reset();return this},create:function create(t,n){var r;"function"!=typeof t?t=function(){}:r=sinon.functionName(t),n||(n=t.length);var o=createProxy(t,n);return sinon.extend(o,spy),delete o.create,sinon.extend(o,t),o.reset(),o.prototype=t.prototype,o.displayName=r||"spy",o.toString=sinon.functionToString,o.instantiateFake=sinon.spy.create,o.id="spy#"+uuid++,o},invoke:function invoke(t,n,r){var o,i,a=matchingFake(this.fakes,r);incrementCallCount.call(this),push.call(this.thisValues,n),push.call(this.args,r),push.call(this.callIds,callId++),createCallProperties.call(this);try{this.invoking=!0,i=a?a.invoke(t,n,r):(this.func||t).apply(n,r),this.getCall(this.callCount-1).calledWithNew()&&"object"!=typeof i&&(i=n)}catch(t){o=t}finally{delete this.invoking}if(push.call(this.exceptions,o),push.call(this.returnValues,i),push.call(this.stacks,(new Error).stack),createCallProperties.call(this),void 0!==o)throw o;return i},named:function named(t){return this.displayName=t,this},getCall:function getCall(t){return t<0||t>=this.callCount?null:sinon.spyCall(this,this.thisValues[t],this.args[t],this.returnValues[t],this.exceptions[t],this.callIds[t],this.stacks[t])},getCalls:function(){var t,n=[];for(t=0;t<this.callCount;t++)n.push(this.getCall(t));return n},calledBefore:function calledBefore(t){return!!this.called&&(!t.called||this.callIds[0]<t.callIds[t.callIds.length-1])},calledAfter:function calledAfter(t){return!(!this.called||!t.called)&&this.callIds[this.callCount-1]>t.callIds[t.callCount-1]},withArgs:function(){var t=slice.call(arguments);if(this.fakes){var n=matchingFake(this.fakes,t,!0);if(n)return n}else this.fakes=[];var r=this,o=this.instantiateFake();o.matchingAguments=t,o.parent=this,push.call(this.fakes,o),o.withArgs=function(){return r.withArgs.apply(r,arguments)};for(var i=0;i<this.args.length;i++)o.matches(this.args[i])&&(incrementCallCount.call(o),push.call(o.thisValues,this.thisValues[i]),push.call(o.args,this.args[i]),push.call(o.returnValues,this.returnValues[i]),push.call(o.exceptions,this.exceptions[i]),push.call(o.callIds,this.callIds[i]));return createCallProperties.call(o),o},matches:function(t,n){var r=this.matchingAguments;if(r.length<=t.length&&sinon.deepEqual(r,t.slice(0,r.length)))return!n||r.length===t.length},printf:function(t){var n,r=this,o=slice.call(arguments,1);return(t||"").replace(/%(.)/g,(function(t,i){return"function"==typeof(n=spyApi.formatters[i])?n.call(null,r,o):isNaN(parseInt(i,10))?"%"+i:sinon.format(o[i-1])}))}};function delegateToCalls(t,n,r,o){spyApi[t]=function(){if(!this.called)return!!o&&o.apply(this,arguments);for(var i,a=0,c=0,l=this.callCount;c<l;c+=1)if((i=this.getCall(c))[r||t].apply(i,arguments)&&(a+=1,n))return!0;return a===this.callCount}}return delegateToCalls("calledOn",!0),delegateToCalls("alwaysCalledOn",!1,"calledOn"),delegateToCalls("calledWith",!0),delegateToCalls("calledWithMatch",!0),delegateToCalls("alwaysCalledWith",!1,"calledWith"),delegateToCalls("alwaysCalledWithMatch",!1,"calledWithMatch"),delegateToCalls("calledWithExactly",!0),delegateToCalls("alwaysCalledWithExactly",!1,"calledWithExactly"),delegateToCalls("neverCalledWith",!1,"notCalledWith",(function(){return!0})),delegateToCalls("neverCalledWithMatch",!1,"notCalledWithMatch",(function(){return!0})),delegateToCalls("threw",!0),delegateToCalls("alwaysThrew",!1,"threw"),delegateToCalls("returned",!0),delegateToCalls("alwaysReturned",!1,"returned"),delegateToCalls("calledWithNew",!0),delegateToCalls("alwaysCalledWithNew",!1,"calledWithNew"),delegateToCalls("callArg",!1,"callArgWith",(function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")})),spyApi.callArgWith=spyApi.callArg,delegateToCalls("callArgOn",!1,"callArgOnWith",(function(){throw new Error(this.toString()+" cannot call arg since it was not yet invoked.")})),spyApi.callArgOnWith=spyApi.callArgOn,delegateToCalls("yield",!1,"yield",(function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")})),spyApi.invokeCallback=spyApi.yield,delegateToCalls("yieldOn",!1,"yieldOn",(function(){throw new Error(this.toString()+" cannot yield since it was not yet invoked.")})),delegateToCalls("yieldTo",!1,"yieldTo",(function(t){throw new Error(this.toString()+" cannot yield to '"+t+"' since it was not yet invoked.")})),delegateToCalls("yieldToOn",!1,"yieldToOn",(function(t){throw new Error(this.toString()+" cannot yield to '"+t+"' since it was not yet invoked.")})),spyApi.formatters={c:function(t){return sinon.timesInWords(t.callCount)},n:function(t){return t.toString()},C:function(t){for(var n=[],r=0,o=t.callCount;r<o;++r){var i=" "+t.getCall(r).toString();/\n/.test(n[r-1])&&(i="\n"+i),push.call(n,i)}return n.length>0?"\n"+n.join("\n"):""},t:function(t){for(var n=[],r=0,o=t.callCount;r<o;++r)push.call(n,sinon.format(t.thisValues[r]));return n.join(", ")},"*":function(t,n){for(var r=[],o=0,i=n.length;o<i;++o)push.call(r,sinon.format(n[o]));return r.join(", ")}},sinon.extend(spy,spyApi),spy.spyCall=sinon.spyCall,sinon.spy=spy,spy}var isNode="undefined"!=typeof module&&module.exports&&"function"==typeof require,isAMD="function"==typeof define&&"object"==typeof define.amd&&define.amd;function loadDependencies(t,n,r){var o=t("./util/core");t("./call"),t("./extend"),t("./times_in_words"),t("./format"),r.exports=makeApi(o)}isAMD?define(loadDependencies):isNode?loadDependencies(require,module.exports,module):sinonGlobal&&makeApi(sinonGlobal)}("object"==typeof sinon&&sinon), /** * Stub behavior * * @author Christian Johansen (christian@cjohansen.no) * @author Tim Fischbach (mail@timfischbach.de) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */ function(t){var n=Array.prototype.slice,r=Array.prototype.join,o="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(t){setTimeout(t,0)};function throwsException(t,n){return"string"==typeof t?(this.exception=new Error(n||""),this.exception.name=t):this.exception=t||new Error("Error"),this}function makeApi(t){function callCallback(i,a){if("number"==typeof i.callArgAt){var c=function getCallback(t,r){var o,i=t.callArgAt;if(i>=0)return r[i];-1===i&&(o=r),-2===i&&(o=n.call(r).reverse());for(var a=t.callArgProp,c=0,l=o.length;c<l;++c){if(!a&&"function"==typeof o[c])return o[c];if(a&&o[c]&&"function"==typeof o[c][a])return o[c][a]}return null}(i,a);if("function"!=typeof c)throw new TypeError(function getCallbackError(n,o,i){var a;return n.callArgAt<0?(a=n.callArgProp?t.functionName(n.stub)+" expected to yield to '"+n.callArgProp+"', but no object with such a property was passed.":t.functionName(n.stub)+" expected to yield, but no callback was passed.",i.length>0&&(a+=" Received ["+r.call(i,", ")+"]"),a):"argument at index "+n.callArgAt+" is not a function: "+o}(i,c,a));i.callbackAsync?o((function(){c.apply(i.callbackContext,i.callbackArguments)})):c.apply(i.callbackContext,i.callbackArguments)}}var i={create:function create(n){var r=t.extend({},t.behavior);return delete r.create,r.stub=n,r},isPresent:function isPresent(){return"number"==typeof this.callArgAt||this.exception||"number"==typeof this.returnArgAt||this.returnThis||this.returnValueDefined},invoke:function invoke(t,n){if(callCallback(this,n),this.exception)throw this.exception;return"number"==typeof this.returnArgAt?n[this.returnArgAt]:this.returnThis?t:this.returnValue},onCall:function onCall(t){return this.stub.onCall(t)},onFirstCall:function onFirstCall(){return this.stub.onFirstCall()},onSecondCall:function onSecondCall(){return this.stub.onSecondCall()},onThirdCall:function onThirdCall(){return this.stub.onThirdCall()},withArgs:function withArgs(){throw new Error('Defining a stub by invoking "stub.onCall(...).withArgs(...)" is not supported. Use "stub.withArgs(...).onCall(...)" to define sequential behavior for calls with certain arguments.')},callsArg:function callsArg(t){if("number"!=typeof t)throw new TypeError("argument index is not number");return this.callArgAt=t,this.callbackArguments=[],this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgOn:function callsArgOn(t,n){if("number"!=typeof t)throw new TypeError("argument index is not number");if("object"!=typeof n)throw new TypeError("argument context is not an object");return this.callArgAt=t,this.callbackArguments=[],this.callbackContext=n,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgWith:function callsArgWith(t){if("number"!=typeof t)throw new TypeError("argument index is not number");return this.callArgAt=t,this.callbackArguments=n.call(arguments,1),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},callsArgOnWith:function callsArgWith(t,r){if("number"!=typeof t)throw new TypeError("argument index is not number");if("object"!=typeof r)throw new TypeError("argument context is not an object");return this.callArgAt=t,this.callbackArguments=n.call(arguments,2),this.callbackContext=r,this.callArgProp=void 0,this.callbackAsync=!1,this},yields:function(){return this.callArgAt=-1,this.callbackArguments=n.call(arguments,0),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsRight:function(){return this.callArgAt=-2,this.callbackArguments=n.call(arguments,0),this.callbackContext=void 0,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsOn:function(t){if("object"!=typeof t)throw new TypeError("argument context is not an object");return this.callArgAt=-1,this.callbackArguments=n.call(arguments,1),this.callbackContext=t,this.callArgProp=void 0,this.callbackAsync=!1,this},yieldsTo:function(t){return this.callArgAt=-1,this.callbackArguments=n.call(arguments,1),this.callbackContext=void 0,this.callArgProp=t,this.callbackAsync=!1,this},yieldsToOn:function(t,r){if("object"!=typeof r)throw new TypeError("argument context is not an object");return this.callArgAt=-1,this.callbackArguments=n.call(arguments,2),this.callbackContext=r,this.callArgProp=t,this.callbackAsync=!1,this},throws:throwsException,throwsException,returns:function returns(t){return this.returnValue=t,this.returnValueDefined=!0,this.exception=void 0,this},returnsArg:function returnsArg(t){if("number"!=typeof t)throw new TypeError("argument index is not number");return this.returnArgAt=t,this},returnsThis:function returnsThis(){return this.returnThis=!0,this}};function createAsyncVersion(t){return function(){var n=this[t].apply(this,arguments);return this.callbackAsync=!0,n}}for(var a in i)i.hasOwnProperty(a)&&a.match(/^(callsArg|yields)/)&&!a.match(/Async/)&&(i[a+"Async"]=createAsyncVersion(a));return t.behavior=i,i}var i="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(t,n,r){var o=t("./util/core");t("./extend"),r.exports=makeApi(o)}"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):i?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon),function(t){function makeApi(t){function walkInternal(t,n,r,o){var i,a;if("function"==typeof Object.getOwnPropertyNames)Object.getOwnPropertyNames(t).forEach((function(i){var a="function"==typeof Object.getOwnPropertyDescriptor(t,i).get?o:t;n.call(r,a[i],i,a)})),(i=Object.getPrototypeOf(t))&&walkInternal(i,n,r,o);else for(a in t)n.call(r,t[a],a,t)}return t.walk=function walk(t,n,r){return walkInternal(t,n,r,t)},t.walk}function loadDependencies(t,n,r){var o=t("./util/core");r.exports=makeApi(o)}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Stub functions * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */ function(t){function makeApi(t){function stub(n,r,o){if(o&&"function"!=typeof o&&"object"!=typeof o)throw new TypeError("Custom stub should be a function or a property descriptor");var i;if(o){if("function"==typeof o)i=t.spy&&t.spy.create?t.spy.create(o):o;else if(i=o,t.spy&&t.spy.create)for(var a=t.objectKeys(i),c=0;c<a.length;c++)i[a[c]]=t.spy.create(i[a[c]])}else{var l=0;"object"==typeof n&&"function"==typeof n[r]&&(l=n[r].length),i=stub.create(l)}return n||void 0!==r?void 0===r&&"object"==typeof n?(t.walk(n||{},(function(r,o,i){i!==Object.prototype&&"constructor"!==o&&"function"==typeof t.getPropertyDescriptor(i,o).value&&stub(n,o)})),n):t.wrapMethod(n,r,i):t.stub.create()}function getDefaultBehavior(n){return n.defaultBehavior||function getParentBehaviour(t){return t.parent&&getCurrentBehavior(t.parent)}(n)||t.behavior.create(n)}function getCurrentBehavior(t){var n=t.behaviors[t.callCount-1];return n&&n.isPresent()?n:getDefaultBehavior(t)}var n=0,r={create:function create(r){var functionStub=function(){return getCurrentBehavior(functionStub).invoke(this,arguments)};functionStub.id="stub#"+n++;var o=functionStub;return(functionStub=t.spy.create(functionStub,r)).func=o,t.extend(functionStub,stub),functionStub.instantiateFake=t.stub.create,functionStub.displayName="stub",functionStub.toString=t.functionToString,functionStub.defaultBehavior=null,functionStub.behaviors=[],functionStub},resetBehavior:function(){var t;if(this.defaultBehavior=null,this.behaviors=[],delete this.returnValue,delete this.returnArgAt,this.returnThis=!1,this.fakes)for(t=0;t<this.fakes.length;t++)this.fakes[t].resetBehavior()},onCall:function onCall(n){return this.behaviors[n]||(this.behaviors[n]=t.behavior.create(this)),this.behaviors[n]},onFirstCall:function onFirstCall(){return this.onCall(0)},onSecondCall:function onSecondCall(){return this.onCall(1)},onThirdCall:function onThirdCall(){return this.onCall(2)}};function createBehavior(n){return function(){return this.defaultBehavior=this.defaultBehavior||t.behavior.create(this),this.defaultBehavior[n].apply(this.defaultBehavior,arguments),this}}for(var o in t.behavior)t.behavior.hasOwnProperty(o)&&!r.hasOwnProperty(o)&&"create"!==o&&"withArgs"!==o&&"invoke"!==o&&(r[o]=createBehavior(o));return t.extend(stub,r),t.stub=stub,stub}var n="undefined"!=typeof module&&module.exports&&"function"==typeof require;function loadDependencies(t,n,r){var o=t("./util/core");t("./behavior"),t("./spy"),t("./extend"),r.exports=makeApi(o)}"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(loadDependencies):n?loadDependencies(require,module.exports,module):t&&makeApi(t)}("object"==typeof sinon&&sinon), /** * Mock functions. * * @author Christian Johansen (christian@cjohansen.no) * @license BSD * * Copyright (c) 2010-2013 Christian Johansen */ function(t){function makeApi(t){var n=[].push,r=t.match;function mock(n){return n?mock.create(n):t.expectation.create("Anonymous mock")}function each(t,n){if(t)for(var r=0,o=t.length;r<o;r+=1)n(t[r])}function arrayEquals(n,r,o){if(o&&n.length!==r.length)return!1;for(var i=0,a=n.length;i<a;i++)if(!t.deepEqual(n[i],r[i]))return!1;return!0}t.extend(mock,{create:function create(n){if(!n)throw new TypeError("object is null");var r=t.extend({},mock);return r.object=n,delete r.create,r},expects:function expects(r){if(!r)throw new TypeError("method is falsy");if(this.expectations||(this.expectations={},this.proxies=[]),!this.expectations[r]){this.expectations[r]=[];var o=this;t.wrapMethod(this.object,r,(function(){return o.invokeMethod(r,this,arguments)})),n.call(this.proxies,r)}var i=t.expectation.create(r);return n.call(this.expectations[r],i),i},restore:function restore(){var t=this.object;each(this.proxies,(function(n){"function"==typeof t[n].restore&&t[n].restore()}))},verify:function verify(){var r=this.expectations||{},o=[],i=[];return each(this.proxies,(function(t){each(r[t],(function(t){t.met()?n.call(i,t.toString()):n.call(o,t.toString())}))})),this.restore(),o.length>0?t.expectation.fail(o.concat(i).join("\n")):i.length>0&&t.expectation.pass(o.concat(i).join("\n")),!0},invokeMethod:function invokeMethod(r,o,i){var a,c,l=this.expectations&&this.expectations[r]?this.expectations[r]:[],u=[],f=i||[];for(a=0;a<l.length;a+=1)arrayEquals(l[a].expectedArguments||[],f,l[a].expectsExactArgCount)&&u.push(l[a]);for(a=0;a<u.length;a+=1)if(!u[a].met()&&u[a].allowsCall(o,i))return u[a].apply(o,i);var d=[],h=0;for(a=0;a<u.length;a+=1)u[a].allowsCall(o,i)?c=c||u[a]:h+=1;if(c&&0===h)return c.apply(o,i);for(a=0;a<l.length;a+=1)n.call(d," "+l[a].toString());d.unshift("Unexpected call: "+t.spyCall.toString.call({proxy:r,args:i})),t.expectation.fail(d.join("\n"))}});var o=t.timesInWords,i=Array.prototype.slice;function receivedMaxCalls(t){return"number"==typeof t.maxCalls&&t.callCount===t.maxCalls}function verifyMatcher(t,n){return r&&r.isMatcher(t)&&t.test(n)||!0}return t.expectation={minCalls:1,maxCalls:1,create:function create(n){var r=t.extend(t.stub.create(),t.expectation);return delete r.create,r.method=n,r},invoke:function invoke(n,r,o){return this.verifyCallAllowed(r,o),t.spy.invoke.apply(this,arguments)},atLeast:function atLeast(t){if("number"!=typeof t)throw new TypeError("'"+t+"' is not number");return this.limitsSet||(this.maxCalls=null,this.limitsSet=!0),this.minCalls=t,this},atMost:function atMost(t){if("number"!=typeof t)throw new TypeError("'"+t+"' is not number");return this.limitsSet||(this.minCalls=null,this.limitsSet=!0),this.maxCalls=t,this},never:function never(){return this.exactly(0)},once:function once(){return this.exactly(1)},twice:function twice(){return this.exactly(2)},thrice:function thrice(){return this.exactly(3