reporting.mocks
Helper functions to facilitate two-way communication when writing tests for your extension.
closeReport()
closeReport():
void
Fires the report-closed
event, which will trigger any report-closed
event listeners.
Returns
void
createReport()
createReport():
void
Fires the report-created
event, which will trigger any report-created
event listeners.
Returns
void
initialize()
initialize():
void
Initialize the SDK for testing. This will create the Broadcast Channels for both sending and receiving events. You must call this before attempting to use any other functions in this module.
Returns
void
respondToLastConfirmation()
respondToLastConfirmation(
status
):void
Fires the confirm-response
event for the latest confirmation request.
After responding to the latest confirmation request, that request is removed from the queue.
The list functions as a stack.
Calling this with confirmed
will trigger the onConfirm
callback.
Calling this with cancelled
will trigger the onCancel
callback (if provided).
Because how the underlying Broadcast Channels pass messages (and how JavaScript handles events), you'll want to wrap this in a vi.waitFor
:
await vi.waitFor(() => reporting.mocks.respondToLastConfirmation(...));
Calling this without firing a confirm-response
event first will result in an error.
Parameters
Parameter | Type | Description |
---|---|---|
status | "confirmed" | "cancelled" | Whether the "test user" has either confirmed or cancelled the confirmation request. |
Returns
void
updateReport()
updateReport(
reportContent
):void
Fires the report-updated
event, which will trigger any report-updated
event listeners.
Parameters
Parameter | Type | Description |
---|---|---|
reportContent | string | The textual representation of the report. |
Returns
void