Need advice about simple custom assert
I'm trying to create really simple assert to simplify calls like this(as I have a lot of them):
- assert.equal(typeof(externalFunction), "function", "externalFunction() must be defined");
So I've tried this:
- QUnit.assert.isFunction = function( testfunc, message ) {
message = message || ( testfunc ? "okay" : "failed, expected argument to be function, was: " +
QUnit.dump.parse( testfunc ) );
this.pushResult( {
result: "function" == typeof(testfunc),
actual: typeof(testfunc),
expected: "function",
message: message
} );
}
It works for defined functions, but throws error "ReferenceError: badfakefunction is not defined" for undefined function
How to create proper assert in my case?