fix(core): update
This commit is contained in:
parent
9d065a54e6
commit
f5f6e40fff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartexpect',
|
||||
version: '1.0.16',
|
||||
version: '1.0.17',
|
||||
description: 'manage expectations in code'
|
||||
}
|
||||
|
@ -380,7 +380,12 @@ export class Assertion {
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -404,10 +409,7 @@ export class Assertion {
|
||||
|
||||
return true;
|
||||
}
|
||||
const partialMatch = deepEqual(
|
||||
this.getObjectToTestReference(),
|
||||
objectArg
|
||||
); // Note: Implement a deep comparison function or use one from a library
|
||||
const partialMatch = deepEqual(this.getObjectToTestReference(), objectArg); // Note: Implement a deep comparison function or use one from a library
|
||||
if (!partialMatch) {
|
||||
throw new Error(
|
||||
`${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() {
|
||||
return this.runCheck(() => {
|
||||
if (!(this.getObjectToTestReference() instanceof Date)) {
|
||||
|
Loading…
Reference in New Issue
Block a user