import type { State } from "../state/state.js"; import type { Conditions } from "./conditions.js"; import { ConditionsContextBase } from "./types.js"; type EitherCallback = (con: C) => any; type EitherTuple = [string, EitherCallback]; declare class ConditionGrouping, S extends State = Context["state"], C = Conditions> { /** * Loops through every item in subject's collection, executing provided function. * If one of the items fail any assertions, whole `every` block fails. * * Each item is automatically set as the `subject` within each iteration. * After all iterations are done, the `subject` will be reset back to what it originally was. * * @param predicate a function in style of native `array.forEach`, * but first argument is new Conditions instance. * This `test` will have its own subject set to each item of current subject. * @example * ```ts * test().get("chosenCards").children.every((con, item, index, array) => { * test().its("rank").oneOf(["2", "3"]) * }) * ``` * @yields back anything that was before `.every()` command so you can chain it further */ every(predicate: (test: C, item: any, index: number | string, collection: any) => void): this; /** * Loops through every item in subject's collection, executing provided function. * At least one item needs to pass tests for this whole block to pass. * If all items fail - whole block fails. * * Each item is automatically set as the `subject` within each iteration. * After all iterations are done, the `subject` will be reset back to what it originally was. * * @param predicate a function in style of native `array.some`, * but first argument is new Conditions instance. * This `test` will have its own subject set to each item of current subject. * @example * ```ts * test().set(chosenCards).some((con, item, index, array) => { * test().its("rank").matchesPropOf(pileTop) * }) * ``` * @yields back the subject which was present before executing `.some()` command so you can chain it further. */ some(predicate: (test: C, item: any, index: number | string, collection: any) => void): this; /** * Checks if at least one of the functions pass. * Resets `subject` back to `state` before each iteration. * * Effectively works like `OR` in logical operations * * @example * ```ts * // Will pass with the first statement and ignore the rest * test().either( * () => test().set(1).equals(1), * () => test().set(0).equals(1), * () => test().set(0).equals(1) * ) * * // Both statements fail, will throw with top message: "none passed" * test("none passed").either( * () => test("zero is one").set(0).equals(1), * () => test("one is two").set(1).equals(2) * ) * ``` */ either(groupName: string, ...args: (EitherCallback | EitherTuple)[]): this; either(...args: (EitherCallback | EitherTuple)[]): this; } export { ConditionGrouping };