Remote / foldkit-remote/testing

MessageRunOptions

interface · packages/remote/src/scenario.ts:566

interface MessageRunOptions<Model, Message> {
  readonly app: {
    readonly initial: Model
    readonly update: (
      model: Model,
      message: Message,
    ) => {
      readonly model: Model
    }
  }
  readonly readers: Readonly<Record<string, (model: Model) => unknown>>
  readonly judge?:
    | ((
        before: Model,
        after: Model,
      ) => Option.Option<{
        readonly id: string
      }>)
    | undefined
  readonly evidence?:
    | {
        readonly transition: string
        readonly laws: ReadonlyArray<string>
      }
    | undefined
}

What runMessages runs over: the application, how to read its Model, and the laws that judge a step.

Members

MessageRunOptions.app

property · packages/remote/src/scenario.ts:567

readonly app: {
  readonly initial: Model
  readonly update: (
    model: Model,
    message: Message,
  ) => {
    readonly model: Model
  }
}

MessageRunOptions.readers

property · packages/remote/src/scenario.ts:572

readonly readers: Readonly<Record<string, (model: Model) => unknown>>

Named readings of the Model, so a scenario survives a change to how the Model holds its state.

MessageRunOptions.judge

property · packages/remote/src/scenario.ts:574

readonly judge?:
  | ((
      before: Model,
      after: Model,
    ) => Option.Option<{
      readonly id: string
    }>)
  | undefined

The first law the step from before to after breaks, as a contract's judge says.

MessageRunOptions.evidence

property · packages/remote/src/scenario.ts:578

readonly evidence?:
  | {
      readonly transition: string
      readonly laws: ReadonlyArray<string>
    }
  | undefined

With it, a scenario with no mismatch issues a Scenario record for transition against each of laws.