@@ -10,6 +10,30 @@ chai.Assertion.addMethod('notStrictEqual', function (ER) {
10
10
) ;
11
11
} ) ;
12
12
13
+ chai . Assertion . addMethod ( 'caseInsensitiveEqual' , function ( ER ) {
14
+ const obj = this . _obj ;
15
+
16
+ this . assert (
17
+ obj . toLowerCase ( ) === ER . toLowerCase ( ) ,
18
+ 'expected #{this} to equal #{exp}' ,
19
+ 'expected #{this} to not equal #{exp}' ,
20
+ ER ,
21
+ obj
22
+ ) ;
23
+ } ) ;
24
+
25
+ chai . Assertion . addMethod ( 'satisfy' , function ( predicate ) {
26
+ const actual = this . _obj ;
27
+
28
+ this . assert (
29
+ predicate ( actual ) ,
30
+ 'expected #{this} to satisfy #{exp}' ,
31
+ 'expected #{this} to not satisfy #{exp}' ,
32
+ predicate . toString ( ) ,
33
+ actual
34
+ ) ;
35
+ } ) ;
36
+
13
37
export const validations = {
14
38
EQUAL : 'equal' ,
15
39
DEEPLY_EQUAL : 'deeply equal' ,
@@ -23,7 +47,9 @@ export const validations = {
23
47
LESS : 'less than' ,
24
48
HAVE_TYPE : 'have type' ,
25
49
INCLUDE_MEMBERS : 'include member' ,
26
- HAVE_PROPERTY : 'have property'
50
+ HAVE_PROPERTY : 'have property' ,
51
+ CASE_INSENSITIVE_EQUAL : 'case insensitive equal' ,
52
+ SATISFY : 'satisfy'
27
53
} ;
28
54
29
55
const isClause = '(?:is |do |does |to )?' ;
@@ -50,6 +76,8 @@ const validationFns = {
50
76
[ validations . HAVE_TYPE ] : ( expectClause , ER ) => expectClause . a ( ER ) ,
51
77
[ validations . INCLUDE_MEMBERS ] : ( expectClause , ER ) => expectClause . include . members ( ER ) ,
52
78
[ validations . HAVE_PROPERTY ] : ( expectClause , ER ) => expectClause . have . property ( ER ) ,
79
+ [ validations . CASE_INSENSITIVE_EQUAL ] : ( expectClause , ER ) => expectClause . caseInsensitiveEqual ( ER ) ,
80
+ [ validations . SATISFY ] : ( expectClause , ER ) => expectClause . satisfy ( ER ) ,
53
81
} ;
54
82
55
83
/**
0 commit comments