Skip to content

Commit

Permalink
assert.partialEqual implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
izelnakri committed Jan 14, 2022
1 parent 0e105de commit 078d2ea
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,45 @@ class Assert {
} );
}

partialEqual( actual, expected, message ) {
[ actual, expected ] = Object.keys( expected ).reduce(
( result, key ) => {
result[ 0 ][ key ] = actual[ key ];
result[ 1 ][ key ] = expected[ key ];

return result;
},
[ {}, {} ]
);

this.pushResult( {
result: equiv( actual, expected ),
actual,
expected,
message
} );
}

notPartialEqual( actual, expected, message ) {
[ actual, expected ] = Object.keys( expected ).reduce(
( result, key ) => {
result[ 0 ][ key ] = actual[ key ];
result[ 1 ][ key ] = expected[ key ];

return result;
},
[ {}, {} ]
);

this.pushResult( {
result: !equiv( actual, expected ),
actual,
expected,
message,
negative: true
} );
}

deepEqual( actual, expected, message ) {
this.pushResult( {
result: equiv( actual, expected ),
Expand Down

0 comments on commit 078d2ea

Please sign in to comment.