UNPKG

@assertive-ts/core

Version:

A type-safe fluent assertion library

128 lines (127 loc) 3.53 kB
import { Assertion } from "./Assertion"; /** * Encapsulates assertion methods applicable to values of type string */ export declare class StringAssertion extends Assertion<string> { constructor(actual: string); /** * Check if the string is empty. That is, when the string does not contain * any characters. * * @example * ``` * expect("").toBeEmpty(); * ``` * * @returns the assertion instance */ toBeEmpty(): this; /** * Check if the string is blank. That is, when the string consists of one or * more whitespaces only. * * @example * ``` * expect(" ").toBeBlank(); * ``` * * @returns the assertion instance */ toBeBlank(): this; /** * Check if the string value is equal to another string. The comparison is * not case sensitive, i.e. it ignores the cases of both string values. * * @example * ``` * expect("hello world").toBeEqualIgnoringCase("HELLO WORLD"); * ``` * * @returns the assertion instance */ toBeEqualIgnoringCase(text: string): this; /** * A convenience alias of `.toBeEqualIgnoringCase(..)` assertion. * * @example * ``` * expect("hello world").toBeEqualCaseInsensitive("HELLO WORLD"); * ``` * * @see {@link StringAssertion.toBeEqualIgnoringCase toBeEqualIgnoringCase} */ toBeEqualCaseInsensitive(text: string): this; /** * Check if the string value contains the passed string. This check compares * both strings in a case sensitive fashion. * * @example * ``` * expect("Hello World").toContain("World"); * ``` * * @param text the text the value should contain * @returns the assertion instance */ toContain(text: string): this; /** * Check if the string value contains the passed string. This check compares * both strings ignoring their cases. * * @example * ``` * expect("HELLO WORLD").toContainIgnoringCase("World"); * ``` * * @param text the text the value should contain (ignoring case) * @returns the assertion instance */ toContainIgnoringCase(text: string): this; /** * A convenience alias of `.toContainIgnoringCase(..)` assertion. * * @example * ``` * expect("HELLO WORLD").toContainCaseInsensitive("World"); * ``` * * @see {@link StringAssertion.toContainIgnoringCase toContainIgnoringCase} */ toContainCaseInsensitive(text: string): this; /** * Check if the string value starts with the passed string * * @example * ``` * expect("Lorem Ipsum").toStartWith("Lorem"); * ``` * * @param text the text he value should start with * @returns the assertion instance */ toStartWith(text: string): this; /** * Check if the string value ends with the passed string * * @example * ``` * expect("Lorem Ipsum").toEndWith("Ipsum"); * ``` * * @param text the text he value should end with * @returns the assertion instance */ toEndWith(text: string): this; /** * Check if the string value matches a regular expression. * * @example * ``` * expect("www.helloworld.com").toMatchRegex(/www\..*\.com/); * ``` * * @param regex the regular expression to match * @returns the assertion instance */ toMatchRegex(regex: RegExp): this; }