-
Notifications
You must be signed in to change notification settings - Fork 3
/
expectThat.mocha.min.js.pp
1 lines (1 loc) · 4.42 KB
/
expectThat.mocha.min.js.pp
1
var expectThatApi,root;root=typeof exports!="undefined"&&exports!==null?exports:window,expectThatApi=function(a){return{version:"0.2.2.2",init:function(a){var b;return b=this,Object.prototype.should=function(c){return b.evaluateAssertion(a,!0,this,c)},Object.prototype.shouldnt=function(c){return b.evaluateAssertion(a,!1,this,c)},this},executeThrowAssertion:function(a,b,c){return typeof c.expected!="undefined"?a.throwsException(b):a.throwsException()},executeEqualToAssertion:function(a,b,c){return a?b.isEqualTo(c):b.isNotEqualTo(c)},executeBooleanAssertion:function(a,b,c,d,e){var f;if(typeof d.expr!="function")throw"The provided custom assertion expression for "+d.assertionType+" is invalid.\nCustom assertion expressions should be defined as:\n(actual, expected) -> <some function using actual and expression>.";return f=e.assert(d.expr(b,c)),a?f.isTrue():f.isFalse()},executeAssertion:function(a,b,c,d,e,f,g){if(a===null||typeof a=="undefined")return;return typeof c!="undefined"?c==="throw"?this.executeThrowAssertion(a,e,f):this.executeBooleanAssertion(b,d,e,f,g):this.executeEqualToAssertion(b,a,e)},evaluateAssertion:function(a,b,c,d){var e,f,g,h;return h=d,g=d,typeof d=="function"&&(g=d()),typeof g!="undefined"&&g!==null&&(f=g.assertionType,typeof g.expected!="undefined"&&(h=g.expected)),e=a.assert(c),this.executeAssertion(e,b,f,c,h,g,a)}}}(expectThatApi||(expectThatApi={})),function(a){return a.util={extend:function(a,b){var c;for(c in b)b.hasOwnProperty(c)&&a&&(a[c]=b[c]);return a}},this}(expectThatApi||(expectThatApi={})),function(a){return a.api={be:function(a){return a},to:function(a){return a},equal:function(a){return a},throwException:function(a){return{assertionType:"throw",expected:a}},extendApi:function(b,c,d){var e;return Object.prototype.should||a.init(c),typeof d=="function"&&typeof b!="function"?(b=d,e=b.toString().match(/^[^\{]*\{((.*\s*)*)\}/m)[1],e=e.replace(/\);/g,"").replace(/[(\^(?)]/g," ").replace(/.should/g," should").replace(/return/g," ").replace(/shouldnt/g,"shouldn't").replace(/void 0/g,"null").replace(/!= null/g,"").replace(/typeof null !== "undefined" && null !== null/g,"undefined").replace(/^\s\s*/,"").replace(/\s\s*$/,"")):e=d,[b,e]}},a.util.extend(a,a.api)}(expectThatApi||(expectThatApi={})),function(a){return a.api.extendedMatchers={greaterThan:function(a){return{assertionType:"greaterThan",expected:a,expr:function(a,b){return a>b}}},lessThan:function(a){return{assertionType:"lessThan",expected:a,expr:function(a,b){return a<b}}},greaterThanOrEqual:function(a){return{assertionType:"greaterThanOrEqual",expected:a,expr:function(a,b){return a>=b}}},lessThanOrEqual:function(a){return{assertionType:"lessThanOrEqual",expected:a,expr:function(a,b){return a<=b}}},strictlyEqual:function(a){return{assertionType:"strictlyEqual",expected:a,expr:function(a,b){return a===b}}}},a.util.extend(a,a.api.extendedMatchers)}(expectThatApi||(expectThatApi={})),function(a,b){return a.api.Mocha={},a.assertionProvider={},a.assertionProvider={assert:function(a){return this.actual=a,this},assertThat:function(a,b){if(!a)throw new Error(b||"failed")},isEqualTo:function(a){return this.assertThat(this.actual==a,"The expected value was: '"+a+"' and the actual value was: '"+this.actual+"'.")},isNotEqualTo:function(a){return this.assertThat(this.actual!=a,"The expected value was: '"+a+"' and the actual value was: '"+this.actual+"'.")},isTrue:function(){return this.assertThat(this.actual,"The expected value was: '{expected}' and the actual value was: '"+this.actual+"'.")},isFalse:function(){return this.assertThat(!this.actual,"The expected value was: '{expected}' and the actual value was: '"+this.actual+"'.")},throwsException:function(a){try{return this.actual(),this.assertThat(!1,"The function did not throw an exception")}catch(b){return typeof a!="undefined"&&a!==null?this.assertThat(b===a,"The function threw an exception, however, the error message did not match the provided\nexpected error message. The expected error message was '"+a+"' and the actual error message was\n'"+b+"'."):this.assertThat(!0,"The actual error message was '"+b+"'.")}}},a.util.extend(a.api.mocha,a.assertionProvider),a.api.mocha={expectThat:function(b,c){var d,e,f;return e=a.api.extendApi(c,a.assertionProvider,b),d=e[0],f=e[1],it(f,d)}},a.util.extend(a,a.api.mocha),b.equal=a.api.equal,b.be=a.api.be,b.to=a.api.to,b.throwException=a.api.throwException,b.expectThat=a.expectThat,b.expectThatApi=a,a.util.extend(b,a.api.extendedMatchers),this}(expectThatApi||(expectThatApi={}),root)