Skip to content

Commit 142157d

Browse files
chore: update tests
1 parent 2cc1c33 commit 142157d

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/system-tests/src/consumer.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ describe('sqs-consumer integration surface', () => {
1515
const sqs = new SQSClient({ region: 'us-east-1' });
1616
const body = JSON.stringify({ hello: 'world' });
1717

18-
sqsMock.on(ReceiveMessageCommand).resolvesOnce({
19-
Messages: [
20-
{
21-
MessageId: '1',
22-
ReceiptHandle: 'abc',
23-
Body: body
24-
}
25-
]
26-
});
27-
28-
sqsMock.on(ReceiveMessageCommand).resolves({ Messages: [] });
18+
sqsMock
19+
.on(ReceiveMessageCommand)
20+
.resolvesOnce({
21+
Messages: [
22+
{
23+
MessageId: '1',
24+
ReceiptHandle: 'abc',
25+
Body: body
26+
}
27+
]
28+
})
29+
.resolves({ Messages: [] });
2930
sqsMock.on(DeleteMessageCommand).resolves({});
3031

3132
const processedBodies: string[] = [];
@@ -35,6 +36,7 @@ describe('sqs-consumer integration surface', () => {
3536
sqs,
3637
handleMessage: async (message) => {
3738
processedBodies.push(message.Body ?? '');
39+
return message;
3840
}
3941
});
4042

packages/system-tests/src/producer.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Producer } from 'sqs-producer';
2-
import { SQSClient, SendMessageCommand } from '@aws-sdk/client-sqs';
2+
import { SQSClient, SendMessageBatchCommand } from '@aws-sdk/client-sqs';
33
import { mockClient } from 'aws-sdk-client-mock';
44
import { beforeEach, describe, expect, it } from 'vitest';
55

@@ -13,7 +13,7 @@ beforeEach(() => {
1313
describe('sqs-producer integration surface', () => {
1414
it('sends a message payload with attributes', async () => {
1515
const sqs = new SQSClient({ region: 'us-east-1' });
16-
sqsMock.on(SendMessageCommand).resolves({});
16+
sqsMock.on(SendMessageBatchCommand).resolves({});
1717

1818
const producer = Producer.create({
1919
queueUrl,
@@ -31,12 +31,14 @@ describe('sqs-producer integration surface', () => {
3131
}
3232
});
3333

34-
const calls = sqsMock.commandCalls(SendMessageCommand);
34+
const calls = sqsMock.commandCalls(SendMessageBatchCommand);
3535
expect(calls).toHaveLength(1);
3636
const [{ args }] = calls;
3737
expect(args[0]?.input?.QueueUrl).toBe(queueUrl);
38-
expect(args[0]?.input?.MessageBody).toContain('"hello":"world"');
39-
expect(args[0]?.input?.MessageAttributes?.source).toEqual({
38+
expect(args[0]?.input?.Entries).toHaveLength(1);
39+
const [entry] = args[0]?.input?.Entries ?? [];
40+
expect(entry?.MessageBody).toContain('"hello":"world"');
41+
expect(entry?.MessageAttributes?.source).toEqual({
4042
DataType: 'String',
4143
StringValue: 'system-tests'
4244
});

0 commit comments

Comments
 (0)