import { HttpStep, IHttpStep } from '../../HttpStep.js'

export const NotOkAssertionKind = 'HttpAction#NotOkAssertion'

/**
 * An assertion that makes sure the input has a truly value.
 */
export interface INotOkAssertion extends IHttpStep {
  kind: typeof NotOkAssertionKind
}

/**
 * An assertion that makes sure the input has a truly value.
 */
export class NotOkAssertion extends HttpStep {
  override kind = NotOkAssertionKind

  constructor(init?: INotOkAssertion) {
    super()
    if (typeof init === 'object') {
      this.new(init)
    }
  }

  override new(init: INotOkAssertion): void {
    super.new(init)
    this.kind = NotOkAssertionKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): INotOkAssertion {
    const result: INotOkAssertion = {
      ...super.toJSON(),
      kind: NotOkAssertionKind,
    }
    return result
  }
}
