Skip to content

Commit

Permalink
add push batch test
Browse files Browse the repository at this point in the history
  • Loading branch information
garysassano committed Aug 15, 2023
1 parent cf5f129 commit 4f36128
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions libs/wingsdk/test/shared-aws/queue.inflight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { mockClient } from "aws-sdk-client-mock";
import { test, expect, beforeEach } from "vitest";
import { QueueClient } from "../../src/shared-aws/queue.inflight";
import "aws-sdk-client-mock-jest";

const sqsMock = mockClient(SQSClient);

Expand Down Expand Up @@ -35,6 +36,37 @@ test("push - happy path", async () => {
expect(response).toEqual(undefined);
});

test("push batch - happy path", async () => {
// GIVEN
const QUEUE_URL = "QUEUE_URL";
const MESSAGES = ["MESSAGE1", "MESSAGE2", "MESSAGE3"];
const RESPONSE = {
MessageId: "MESSAGE_ID",
};

sqsMock.on(SendMessageCommand).resolves(RESPONSE);

// WHEN
const client = new QueueClient(QUEUE_URL);
const response = await client.push(...MESSAGES);

// THEN
expect(response).toEqual(undefined);
expect(sqsMock).toHaveReceivedCommandTimes(SendMessageCommand, 3);
expect(sqsMock).toHaveReceivedNthCommandWith(1, SendMessageCommand, {
QueueUrl: QUEUE_URL,
MessageBody: MESSAGES[0],
});
expect(sqsMock).toHaveReceivedNthCommandWith(2, SendMessageCommand, {
QueueUrl: QUEUE_URL,
MessageBody: MESSAGES[1],
});
expect(sqsMock).toHaveReceivedNthCommandWith(3, SendMessageCommand, {
QueueUrl: QUEUE_URL,
MessageBody: MESSAGES[2],
});
});

test("purge - happy path", async () => {
// GIVEN
const QUEUE_URL = "QUEUE_URL";
Expand Down

0 comments on commit 4f36128

Please sign in to comment.