Skip to content

Commit

Permalink
Add in EventBridge assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Hamilton authored and agwhi committed May 14, 2021
1 parent 4d6d5eb commit 4c0f47c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/assertions/toHaveSentEventBridgeMessage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
toHaveSentEventBridgeMessage(sqsResult) {
if (sqsResult.Messages) {
return {
message: () => `expected to have message in EventBridge Bus`,
pass: true,
};
}
return {
message: () => `no message intercepted from EventBridge Bus`,
pass: false,
};
},
};
18 changes: 18 additions & 0 deletions src/assertions/toHaveSentEventWithSourceEqualTo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
toHaveSentEventWithSourceEqualTo(sqsResult, expectedSourceName) {
const receivedSource = JSON.parse(sqsResult.Messages[0].Body).source;
if (receivedSource == expectedSourceName) {
return {
message: () =>
`expected sent event to have source ${expectedSourceName}`,
pass: true,
};
} else {
return {
message: () =>
`sent event source "${receivedSource}" does not match expected source "${expectedSourceName}"`,
pass: false,
};
}
},
};

0 comments on commit 4c0f47c

Please sign in to comment.