diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index 77af8ead..35cc7114 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -590,6 +590,42 @@ assert.isNotFunction = function (val, msg) { new Assertion(val, msg, assert.isNotFunction, true).to.not.be.a('function'); }; +/** + * ### .isAsyncFunction(value, [message]) + * + * Asserts that `value` is a async function. + * + * async function serveTea() { return 'cup of tea'; }; + * assert.isAsyncFunction(serveTea, 'great, we can have tea now'); + * + * @name isAsyncFunction + * @param {Mixed} value + * @param {String} message + * @namespace Assert + * @api public + */ +assert.isAsyncFunction = function (val, msg) { + new Assertion(val, msg, assert.isAsyncFunction, true).to.be.a('asyncfunction'); +}; + +/** + * ### .isNotAsyncFunction(value, [message]) + * + * Asserts that `value` is _not_ a async function. + * + * var serveTea = [ 'heat', 'pour', 'sip' ]; + * assert.isNotAsyncFunction(serveTea, 'great, we have listed the steps'); + * + * @name isNotAsyncFunction + * @param {Mixed} value + * @param {String} message + * @namespace Assert + * @api public + */ +assert.isNotAsyncFunction = function (val, msg) { + new Assertion(val, msg, assert.isNotAsyncFunction, true).to.not.be.a('asyncfunction'); +}; + /** * ### .isObject(value, [message]) * diff --git a/test/assert.js b/test/assert.js index b6914ae4..955450fe 100644 --- a/test/assert.js +++ b/test/assert.js @@ -524,9 +524,6 @@ describe('assert', function () { it('isFunction', function() { var func = function() {}; assert.isFunction(func); - - async function asyncFunction() {}; - assert.isFunction(asyncFunction); err(function () { assert.isFunction({}, 'blah'); @@ -540,6 +537,23 @@ describe('assert', function () { assert.isNotFunction(function () {}, 'blah'); }, "blah: expected [Function] not to be a function"); }); + + it('isAsyncFunction', function() { + async function func() {}; + assert.isAsyncFunction(func); + + err(function () { + assert.isAsyncFunction(function () {}, 'blah'); + }, "blah: expected [Function] to be an asyncfunction"); + }); + + it('isNotAsyncFunction', function () { + assert.isNotAsyncFunction(5); + + err(function () { + assert.isNotAsyncFunction(async function () {}, 'blah'); + }, "blah: expected [Function] not to be an asyncfunction"); + }); it('isArray', function() { assert.isArray([]);