fix(core): update
This commit is contained in:
		| @@ -3,6 +3,6 @@ | |||||||
|  */ |  */ | ||||||
| export const commitinfo = { | export const commitinfo = { | ||||||
|   name: '@push.rocks/smartexpect', |   name: '@push.rocks/smartexpect', | ||||||
|   version: '1.0.16', |   version: '1.0.17', | ||||||
|   description: 'manage expectations in code' |   description: 'manage expectations in code' | ||||||
| } | } | ||||||
|   | |||||||
| @@ -378,20 +378,25 @@ export class Assertion { | |||||||
|         if (obj1 === obj2) { |         if (obj1 === obj2) { | ||||||
|           return true; |           return true; | ||||||
|         } |         } | ||||||
|        |  | ||||||
|         // If either of them is null or not an object |         // If either of them is null or not an object | ||||||
|         if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) { |         if ( | ||||||
|  |           typeof obj1 !== 'object' || | ||||||
|  |           obj1 === null || | ||||||
|  |           typeof obj2 !== 'object' || | ||||||
|  |           obj2 === null | ||||||
|  |         ) { | ||||||
|           return false; |           return false; | ||||||
|         } |         } | ||||||
|        |  | ||||||
|         const keys1 = Object.keys(obj1); |         const keys1 = Object.keys(obj1); | ||||||
|         const keys2 = Object.keys(obj2); |         const keys2 = Object.keys(obj2); | ||||||
|        |  | ||||||
|         // If their properties' count doesn't match |         // If their properties' count doesn't match | ||||||
|         if (keys1.length !== keys2.length) { |         if (keys1.length !== keys2.length) { | ||||||
|           return false; |           return false; | ||||||
|         } |         } | ||||||
|        |  | ||||||
|         // Checking if every property in obj1 has a counterpart in obj2 |         // Checking if every property in obj1 has a counterpart in obj2 | ||||||
|         for (const key of keys1) { |         for (const key of keys1) { | ||||||
|           if (!keys2.includes(key)) { |           if (!keys2.includes(key)) { | ||||||
| @@ -401,13 +406,10 @@ export class Assertion { | |||||||
|             return false; |             return false; | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|        |  | ||||||
|         return true; |         return true; | ||||||
|       }       |       } | ||||||
|       const partialMatch = deepEqual( |       const partialMatch = deepEqual(this.getObjectToTestReference(), objectArg); // Note: Implement a deep comparison function or use one from a library | ||||||
|         this.getObjectToTestReference(), |  | ||||||
|         objectArg |  | ||||||
|       ); // Note: Implement a deep comparison function or use one from a library |  | ||||||
|       if (!partialMatch) { |       if (!partialMatch) { | ||||||
|         throw new Error( |         throw new Error( | ||||||
|           `${this.baseReference} with drill down ${this.propertyDrillDown} does not match the object ${objectArg}` |           `${this.baseReference} with drill down ${this.propertyDrillDown} does not match the object ${objectArg}` | ||||||
| @@ -448,6 +450,28 @@ export class Assertion { | |||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   public toHaveLengthGreaterThan(length: number) { | ||||||
|  |     return this.runCheck(() => { | ||||||
|  |       const obj = this.getObjectToTestReference(); | ||||||
|  |       if (typeof obj.length !== 'number' || obj.length <= length) { | ||||||
|  |         throw new Error( | ||||||
|  |           `${this.baseReference} with drill down ${this.propertyDrillDown} does not have a length greater than ${length}` | ||||||
|  |         ); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public toHaveLengthLessThan(length: number) { | ||||||
|  |     return this.runCheck(() => { | ||||||
|  |       const obj = this.getObjectToTestReference(); | ||||||
|  |       if (typeof obj.length !== 'number' || obj.length >= length) { | ||||||
|  |         throw new Error( | ||||||
|  |           `${this.baseReference} with drill down ${this.propertyDrillDown} does not have a length less than ${length}` | ||||||
|  |         ); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   public toBeDate() { |   public toBeDate() { | ||||||
|     return this.runCheck(() => { |     return this.runCheck(() => { | ||||||
|       if (!(this.getObjectToTestReference() instanceof Date)) { |       if (!(this.getObjectToTestReference() instanceof Date)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user