import { Expectation } from '@serenity-js/core';

/**
 * Creates an [expectation](https://serenity-js.org/api/core/class/Expectation/) that is met when the actual `string` value
 * ends with the resolved value of `expected`.
 *
 * ## Ensuring that a given string ends with an expected substring
 *
 * ```ts
 * import { actorCalled } from '@serenity-js/core'
 * import { Ensure, endsWith } from '@serenity-js/assertions'
 *
 * await actorCalled('Ester').attemptsTo(
 *   Ensure.that('Hello World!', endsWith('!')),
 * )
 * ```
 *
 * @param expected
 *
 * @group Expectations
 */
export const endsWith = Expectation.define(
    'endsWith', 'end with',
    (actual: string, expected: string) =>
        actual.endsWith(expected)
)
