import { Assertion } from '../smartexpect.classes.assertion.js'; /** * Namespace for string-specific matchers */ export class StringMatchers { constructor(private assertion: Assertion) {} toStartWith(prefix: string) { return this.assertion.customAssertion( (value) => (value as string).startsWith(prefix), `Expected string to start with "${prefix}"` ); } toEndWith(suffix: string) { return this.assertion.customAssertion( (value) => (value as string).endsWith(suffix), `Expected string to end with "${suffix}"` ); } toInclude(substring: string) { return this.assertion.customAssertion( (value) => (value as string).includes(substring), `Expected string to include "${substring}"` ); } toMatch(regex: RegExp) { return this.assertion.customAssertion( (value) => regex.test(value as string), `Expected string to match ${regex}` ); } toBeOneOf(values: string[]) { return this.assertion.customAssertion( (value) => (values as string[]).includes(value as string), `Expected string to be one of ${JSON.stringify(values)}` ); } /** Length check for strings */ toHaveLength(length: number) { return this.assertion.customAssertion( (value) => (value as string).length === length, `Expected string to have length ${length}` ); } }