-
Notifications
You must be signed in to change notification settings - Fork 0
/
assertObjectsEqual.js
30 lines (27 loc) · 1.32 KB
/
assertObjectsEqual.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// ********* assertObjectsEqual FUNCTION *********
const eqObjects = require ('./eqObjects');
/** **** FUNCTION IMPLEMENTATION: assertObjectsEqual FUNCTION ****
* Functionality - a function that takes in 2 objects and
* returns true if they are equal and false otherwise
* Code
* ln 1. const - creates assertObjectsEqual to hold function results
* ln 2. const - creates inspect variable to hold values from the inspect
* objects function
* ln 3. let - creates isEqual to hold results from passing two objects
* (two params from this function) to eqObjects if identical
* ln 4. if - takes T/F from eqObjects and returns 1 of 2 actions
* ln 5. return - returns assert passes message with actual object values
* ln 6. else - marks alternate action
* ln 7. return - returns assert fails message with actual object values
*
*/
const assertObjectsEqual = function(actual, expected) {
const inspect = require('util').inspect;
let isEqual = eqObjects(actual, expected);
if (isEqual) {
return console.log(`✅✅✅ Assertion Passed: ${inspect(actual)} === ${inspect(expected)}`);
} else {
return console.log(`❌❌❌ Assertion Failed: ${inspect(actual)} !== ${inspect(expected)}`);
}
};
module.exports = assertObjectsEqual;