@@ -8,6 +8,7 @@ import * as chai from '../../../index.js';
8
8
import { Assertion } from '../assertion.js' ;
9
9
import { flag , inspect } from '../utils/index.js' ;
10
10
import { AssertionError } from 'assertion-error' ;
11
+ import { type } from '../utils/type-detect.js' ;
11
12
12
13
/**
13
14
* ### assert(expression, message)
@@ -590,6 +591,56 @@ assert.isNotFunction = function (val, msg) {
590
591
new Assertion ( val , msg , assert . isNotFunction , true ) . to . not . be . a ( 'function' ) ;
591
592
} ;
592
593
594
+ /**
595
+ * TODO
596
+ */
597
+ assert . isCallable = function ( val , msg ) {
598
+ if ( ! [ 'Function' , 'AsyncFunction' , 'GeneratorFunction' , 'AsyncGeneratorFunction' ] . includes ( type ( val ) ) ) {
599
+ throw new AssertionError (
600
+ msg + ': expected ' + inspect ( val ) + ' to be callable' ,
601
+ undefined ,
602
+ assert . isCallable
603
+ ) ;
604
+ }
605
+ }
606
+
607
+ /**
608
+ * ### .isAsyncFunction(value, [message])
609
+ *
610
+ * Asserts that `value` is a async function.
611
+ *
612
+ * async function serveTea() { return 'cup of tea'; };
613
+ * assert.isAsyncFunction(serveTea, 'great, we can have tea now');
614
+ *
615
+ * @name isAsyncFunction
616
+ * @param {Mixed } value
617
+ * @param {String } message
618
+ * @namespace Assert
619
+ * @api public
620
+ */
621
+ assert . isAsyncFunction = function ( val , msg ) {
622
+ if ( ! [ 'AsyncFunction' , 'AsyncGeneratorFunction' ] . includes ( type ( val ) ) ) {
623
+ throw new AssertionError (
624
+ msg + ': expected ' + inspect ( val ) + ' to be a AsyncFunction' ,
625
+ undefined ,
626
+ assert . isAsyncFunction
627
+ ) ;
628
+ }
629
+ } ;
630
+
631
+ /**
632
+ * TODO
633
+ */
634
+ assert . isGeneratorFunction = function ( val , msg ) {
635
+ if ( ! [ 'GeneratorFunction' , 'AsyncGeneratorFunction' ] . includes ( type ( val ) ) ) {
636
+ throw new AssertionError (
637
+ msg + ': expected ' + inspect ( val ) + ' to be a GeneratorFunction' ,
638
+ undefined ,
639
+ assert . isGeneratorFunction
640
+ ) ;
641
+ }
642
+ }
643
+
593
644
/**
594
645
* ### .isObject(value, [message])
595
646
*
0 commit comments