Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Tracking the removed messages in the mock and fixing a JSDoc tag
Browse files Browse the repository at this point in the history
  • Loading branch information
klcodanr committed Aug 18, 2023
1 parent 558231f commit aa7bbe2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/queue-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class QueueClient {
/**
* Gets the queue records from the context
* @param {import('@adobe/helix-universal').UniversalContext} context
* @returns {Array<import('./queue.js').QueueRecord>} the queue records
* @returns {Array<QueueRecord>} the queue records
*/
static extractQueueRecords(context) {
return context.invocation?.event?.Records || [];
Expand Down
16 changes: 14 additions & 2 deletions packages/queue-client/src/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,29 @@
export class MockQueueClient {
messages = [];

removed = [];

async sendMessage(message) {
const id = this.messages.push(message);
return id.toString();
}

/**
* Reads the message, reading from blob storage if required
* @param {string} messageBody
* @returns {Promise<Object>}
*/
// eslint-disable-next-line class-methods-use-this
async removeMessage() {
// do nothing
async readMessageBody(messageBody) {
return JSON.parse(messageBody);
}

async removeMessage(receiptHandle) {
this.removed.push(receiptHandle);
}

reset() {
this.messages = [];
this.removed = [];
}
}

0 comments on commit aa7bbe2

Please sign in to comment.