Skip to main content
Defined in: testing/MockProvider.ts:231

Extended by

Implements

Constructors

Constructor

Defined in: testing/MockProvider.ts:256

Parameters

Returns

MockProvider

Properties

id

Defined in: testing/MockProvider.ts:232 Stable transport tag (e.g. ‘baileys’, ‘telegram’) — used to namespace conversation keys if one Bot ever runs multiple providers concurrently.

Implementation of

IProvider.id

capabilities

Defined in: testing/MockProvider.ts:233

Implementation of

IProvider.capabilities

selfId

Defined in: testing/MockProvider.ts:234 The bot’s own user id once connected (for group mention matching). Optional.

Implementation of

IProvider.selfId

outbox

Defined in: testing/MockProvider.ts:236

journal

Defined in: testing/MockProvider.ts:241 Chronological journal of inbound messages/interactions (as emitted, before any chaos wrapper) and of every send with the ref it returned. Bounded by maxJournal.

edits

Defined in: testing/MockProvider.ts:243 Edits recorded by editMessage (enabled by streaming 'edit'/'draft' or supports.edit).

drafts

Defined in: testing/MockProvider.ts:245 Draft previews recorded by sendDraft (enabled by streaming: 'draft' or supports.drafts).

deleted

Defined in: testing/MockProvider.ts:247 Messages deleted through deleteMessage (enabled by streaming not 'none' or supports.delete).

acks

Defined in: testing/MockProvider.ts:249 Interaction acks recorded by acknowledgeInteraction, in order.

interactionId

opts?

opts.text?
opts.defer?

textFormatFor?

Defined in: testing/MockProvider.ts:251 Per-chat text format — present only when MockProviderOptions.textFormatFor is given.

Parameters

Returns

TextFormat | undefined

Implementation of

IProvider.textFormatFor

maxJournal

Defined in: testing/MockProvider.ts:253 Journal cap (MockProviderOptions.maxJournal).

starts

Defined in: testing/MockProvider.ts:320 start() calls so far.

stops

Defined in: testing/MockProvider.ts:322 stop() calls so far.

Methods

editMessage()

Defined in: testing/MockProvider.ts:289 Records the edit in edits. Hidden (undefined) unless enabled — see MockProviderOptions.supports.

Parameters

Returns

Promise<SendResult<unknown>>

Implementation of

IProvider.editMessage

acknowledgeInteraction()

Defined in: testing/MockProvider.ts:295 Records the ack in acks (button/callback interactions).

Parameters

Returns

Promise<void>

Implementation of

IProvider.acknowledgeInteraction

deleteMessage()

Defined in: testing/MockProvider.ts:300 Records the ref in deleted. Hidden (undefined) unless enabled — see MockProviderOptions.supports.

Parameters

Returns

Promise<void>

Implementation of

IProvider.deleteMessage

sendDraft()

Defined in: testing/MockProvider.ts:305 Records the draft in drafts. Hidden (undefined) unless enabled — see MockProviderOptions.supports.

Parameters

Returns

Promise<void>

Implementation of

IProvider.sendDraft

stopDraft()

Defined in: testing/MockProvider.ts:310 Simulate the user pressing “stop” on the latest draft that offered it.

Returns

boolean

start()

Defined in: testing/MockProvider.ts:324

Returns

Promise<void>

Implementation of

IProvider.start

stop()

Defined in: testing/MockProvider.ts:328

Returns

Promise<void>

Implementation of

IProvider.stop

send()

Defined in: testing/MockProvider.ts:330 Send normalized content. Rejects with a typed error (section 8) on failure.

Parameters

Returns

Promise<SendResult<unknown>>

Implementation of

IProvider.send

onEvent()

Defined in: testing/MockProvider.ts:337 Subscribe to the normalized event stream. Returns an unsubscriber.

Parameters

Returns

() => void

Implementation of

IProvider.onEvent

downloadMedia()

Defined in: testing/MockProvider.ts:348 Bytes of a simulated media: a copy of the bytes behind the ref (incomingMedia, chat.sendMedia); an empty buffer for a legacy token: null ref (incoming(text, { type: 'image' })). A { url } token without bytes rejects with MediaUnavailableError — the mock never touches the network.

Parameters

Returns

Promise<Buffer<ArrayBufferLike>>

Implementation of

IProvider.downloadMedia

clearJournal()

Defined in: testing/MockProvider.ts:361 Forget the journal (the seq counter keeps growing; outbox is untouched).

Returns

void

incoming()

Defined in: testing/MockProvider.ts:384 Simulate an incoming message.

Parameters

Returns

void

incomingMedia()

Defined in: testing/MockProvider.ts:413 Simulate an inbound media message (type: kind, body = caption). source bytes are what downloadMedia returns; { url } alone is metadata only, and the download then rejects with MediaUnavailableError.

Parameters

Returns

void

incomingLocation()

Defined in: testing/MockProvider.ts:436 Simulate a shared location (type: 'location', ctx.sharedLocation). The body is the place name, else the address, else '' — as the real providers set it.

Parameters

Returns

void

interaction()

Defined in: testing/MockProvider.ts:441 Simulate a UI interaction (button/list row/slash command; kind defaults to 'button').

Parameters

Returns

void

reaction()

Defined in: testing/MockProvider.ts:465 Simulate a reaction to a message (bot.on('reaction'), 'reaction' hooks). to is the reacted message; the sender defaults to from (the chat), as in a DM.

Parameters

Returns

void

call()

Defined in: testing/MockProvider.ts:478 Simulate an inbound call notification (what bot.on('call') and the CALL trigger receive). Reuse the same id to emit later updates of one call. For a group call pass chatId (the group) and isGroup: true; from is the caller.

Parameters

Returns

void