Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bboure committed Jan 19, 2024
1 parent bb71ba5 commit ca5230b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/helpers/cognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type CognitoUserInput = {
*/
username: string;
/**
* An optional cognito client configuration.
* An optional Cognito SDK client configuration.
*/
clientConfig?: CognitoIdentityProviderClientConfig;
};
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ declare global {

interface EventBridgeMatchers {
/**
* Asserts the the EventBridge spy has received an
* Asserts the the spied EventBridge has received an
* event matching the expected object.
*
* @param expected The expected object.
Expand All @@ -126,7 +126,7 @@ declare global {
): Promise<void>;

/**
* Asserts the the EventBridge spy has received an
* Asserts the the spied EventBridge has received an
* event matching the expected object a certain number of times.
*
* @param expected The expected object.
Expand Down
4 changes: 3 additions & 1 deletion src/spies/eventBridge/EventBridgeSpy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class EventBridgeSpy {

/**
* Resets the spy and removes all the events that have been captured.
* This will avoid mixing events from different tests.
*
* Use this method in an `afterEach` block.
*
Expand All @@ -80,7 +81,8 @@ export class EventBridgeSpy {
/**
* Stop spying on the EventBridge bus.
*
* Use this method in an `afterAll` block.
* You should always call this method at the end of your tests,
* usually in an `afterAll` block.
*
* @example
*
Expand Down
15 changes: 14 additions & 1 deletion src/spies/eventBridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export type EventBridgeSpyParams = {
/**
* Creates an EventBridge spy.
*
* Use with {@link expect} and any compatible matcher.
* Use it before your tests to spy on EventBridge events,
* usually in a `beforeAll` block.
*
* Then use the spy with {@link expect} and any compatible matcher.
* @see https://serverlessguru.gitbook.io/sls-jest/matchers/eventbridge
*
* @param params {@link EventBridgeSpyParams}
Expand All @@ -39,6 +42,16 @@ export type EventBridgeSpyParams = {
* beforeAll(async () => {
* spy = await eventBridgeSpy(config);
* });
*
* it('should have event matching object', async () => {
* // do something that triggers an event
* await expect(spy).toHaveEventMatchingObject({
* 'detail-type': 'orderCreated',
* detail: {
* id: order.id,
* },
* });
* });
*/
export const eventBridgeSpy = async (params: EventBridgeSpyParams) => {
const { eventBusName, adapter, config } = params;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cognito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getCognitoClient } from './internal';

type CognitoInput = {
/**
* An optional cognito client configuration.
* An optional Cognito Identity Provider SDK client configuration.
*/
clientConfig?: CognitoIdentityProviderClientConfig;
};
Expand Down

0 comments on commit ca5230b

Please sign in to comment.