diff --git a/ts/smartexpect.classes.assertion.ts b/ts/smartexpect.classes.assertion.ts index 492e870..34fbd1b 100644 --- a/ts/smartexpect.classes.assertion.ts +++ b/ts/smartexpect.classes.assertion.ts @@ -205,6 +205,30 @@ export class Assertion { }); } + public toStartWith(itemArg: any) { + return this.runCheck(() => { + const testObject = this.getObjectToTestReference(); + const result = + typeof testObject === 'string' && + testObject.startsWith(itemArg); + if (!result) { + throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`); + } + }); + } + + public toEndWith(itemArg: any) { + return this.runCheck(() => { + const testObject = this.getObjectToTestReference(); + const result = + typeof testObject === 'string' && + testObject.endsWith(itemArg); + if (!result) { + throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`); + } + }); + } + public property(propertyNameArg: string) { this.propertyDrillDown.push(propertyNameArg); return this;