Skip to content

Commit

Permalink
use withKey
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Sep 19, 2024
1 parent 8b48d15 commit 15f607c
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 295 deletions.
29 changes: 0 additions & 29 deletions tests/resources/BaseTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,6 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" {
super.beforeAll();

addMatchers( {
toHaveKeyWithCase : function( expectation, args = {} ) {
// handle both positional and named arguments
param args.key = "";
if ( structKeyExists( args, 1 ) ) {
args.key = args[ 1 ];
}
param args.message = "";
if ( structKeyExists( args, 2 ) ) {
args.message = args[ 2 ];
}

if ( args.key == "" ) {
expectation.message = "No Key Provided.";
return false;
}

if( !listFind( expectation.actual.keyList(), args.key ) ){
if( listFindNoCase( expectation.actual.keyList(), args.key ) ){
expectation.message = "The key(s) [#args.key#] does exist in the target object, but the Case is incorrect. Found keys are [#structKeyArray( expectation.actual ).toString()#]";
} else {
expectation.message = "The key(s) [#args.key#] does not exist in the target object, with or without case sensitivity. Found keys are [#structKeyArray( expectation.actual ).toString()#]";
}
debug( expectation.actual );
return false;
}

return true;
},

toHaveLengthGT : function( expectation, args = {}, lengthTest=variables.lengthTest ) {
args[ "operator" ] = "GT";
return arguments.lengthTest( expectation, args );
Expand Down
Loading

0 comments on commit 15f607c

Please sign in to comment.