Skip to content

Commit

Permalink
feat: introduce jest matchers (#97)
Browse files Browse the repository at this point in the history
* feat: introduce jest matchers

* fix: use type import for SinonSpyCall

* fix: add @typescript-eslint/no-namespace as eslint rule

replace ignore comment

* fix: rename toHaveReceivedNthCommandWith matcher

* fix: remove notMessage argument from callback

* fix: add missing matcher aliases

* fix: adjust command call format

* fix: test types

Co-authored-by: Maciej Radzikowski <maciej@radzikowski.com.pl>
  • Loading branch information
jurijzahn8019 and m-radzikowski authored Jun 13, 2022
1 parent c66e050 commit b5f2c10
Show file tree
Hide file tree
Showing 7 changed files with 640 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/member-delimiter-style": "warn",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": [
"error",
{
"allowDeclarations": true
}
]
}
}
7 changes: 6 additions & 1 deletion src/awsClientStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ export class AwsStub<TInput extends object, TOutput extends MetadataBearer> impl
this.send = send;
}

/** Returns the class name of the underlying mocked client class */
clientName(): string {
return this.client.constructor.name;
}

/**
* Resets stub. It will replace the stub with a new one, with clean history and behavior.
*/
Expand Down Expand Up @@ -333,7 +338,7 @@ export class CommandBehavior<TInput extends object, TOutput extends MetadataBear
}
}

type AwsCommand<Input extends ClientInput, Output extends ClientOutput, ClientInput extends object = any, ClientOutput extends MetadataBearer = any> = Command<ClientInput, Input, ClientOutput, Output, any>;
export type AwsCommand<Input extends ClientInput, Output extends ClientOutput, ClientInput extends object = any, ClientOutput extends MetadataBearer = any> = Command<ClientInput, Input, ClientOutput, Output, any>;
type CommandResponse<TOutput> = Partial<TOutput> | PromiseLike<Partial<TOutput>>;

export interface AwsError extends Partial<Error>, Partial<MetadataBearer> {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './mockClient';
export * from './awsClientStub';
import './jestMatchers';
Loading

0 comments on commit b5f2c10

Please sign in to comment.