Last active
July 16, 2020 06:13
-
-
Save maatthc/8cebb555bcddc54c7163e199d51a9b49 to your computer and use it in GitHub Desktop.
(JavaScript) Jest test example use of toHaveBeenCalledTimes, objectContaining and arrayContaining in AWS Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Run method', () => { | |
const event: CloudWatchLogsEvent = { | |
awslogs: { | |
data: '', | |
}, | |
} | |
it('should confirm shipments where emitted', async () => { | |
expect.assertions(2) | |
await service.run(event) | |
expect(sendBatchJSONMessages).toHaveBeenCalledTimes(1) | |
const expected = expect.objectContaining({ | |
ExternalOrderId: expect.any(String), | |
OrderId: expect.any(String), | |
}) | |
expect(sendBatchJSONMessages).toHaveBeenCalledWith( | |
'http://localhost:4576/', | |
expect.arrayContaining([expected]), | |
) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment