import { HttpStep } from '../../HttpStep.js';
export const ToBeAssertionKind = 'HttpAction#ToBeAssertion';
export var ToBeTypes;
(function (ToBeTypes) {
    ToBeTypes["string"] = "string";
    ToBeTypes["number"] = "number";
    ToBeTypes["boolean"] = "boolean";
    ToBeTypes["object"] = "object";
    ToBeTypes["array"] = "array";
})(ToBeTypes || (ToBeTypes = {}));
/**
 * An assertion that makes sure the input is of a specific type (string, number, boolean, object, array).
 */
export class ToBeAssertion extends HttpStep {
    kind = ToBeAssertionKind;
    /**
     * The type to expect.
     */
    value;
    constructor(valueOrInit) {
        super();
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'string') {
            this.new({
                kind: ToBeAssertionKind,
                value: valueOrInit,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = ToBeAssertionKind;
        this.value = init.value;
    }
    checkValidity() {
        return !!this.value;
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: ToBeAssertionKind,
        };
        if (this.value) {
            result.value = this.value;
        }
        return result;
    }
}
//# sourceMappingURL=ToBeAssertion.js.map