Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use namespace imports instead of default imports and remove the need to enable esModuleInterop in tsconfig #239

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/aws-sdk-client-mock-jest/src/jestMatchers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-interface */
import assert from 'assert';
import * as assert from 'assert';
import type {MetadataBearer} from '@smithy/types';
import {AwsCommand, AwsStub} from 'aws-sdk-client-mock';
import type {SinonSpyCall} from 'sinon';
Expand Down Expand Up @@ -275,8 +275,8 @@ const processMatch = <CheckData = undefined>({ctx, mockClient, command, check, m
};
message: (params: MessageFunctionParams<CheckData>) => string[];
}): ExpectationResult => {
assert(mockClient instanceof AwsStub, 'The actual must be a client mock instance');
command && assert(
assert.ok(mockClient instanceof AwsStub, 'The actual must be a client mock instance');
command && assert.ok(
command &&
typeof command === 'function' &&
typeof command.name === 'string' &&
Expand Down Expand Up @@ -310,7 +310,7 @@ const processMatch = <CheckData = undefined>({ctx, mockClient, command, check, m
};

const ensureNoOtherArgs = (args: unknown[]): void => {
assert(args.length === 0, 'Too many matcher arguments');
assert.ok(args.length === 0, 'Too many matcher arguments');
};

const baseMatchers: { [P in keyof AwsSdkJestMockBaseMatchers<unknown>]: MatcherFunction<any[]> } = {
Expand Down Expand Up @@ -398,7 +398,7 @@ const baseMatchers: { [P in keyof AwsSdkJestMockBaseMatchers<unknown>]: MatcherF
...other: unknown[]
) {
ensureNoOtherArgs(other);
assert(
assert.ok(
call && typeof call === 'number' && call > 0,
'Call number must be a number greater than 0',
);
Expand Down Expand Up @@ -453,7 +453,7 @@ const baseMatchers: { [P in keyof AwsSdkJestMockBaseMatchers<unknown>]: MatcherF
...other: unknown[]
) {
ensureNoOtherArgs(other);
assert(
assert.ok(
call && typeof call === 'number' && call > 0,
'Call number must be a number greater than 0',
);
Expand Down
6 changes: 3 additions & 3 deletions packages/aws-sdk-client-mock/src/mockClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Client, Command, MetadataBearer} from '@smithy/types';
import sinon, {SinonSandbox, SinonStub} from 'sinon';
import * as sinon from 'sinon';
import {isSinonStub} from './sinon';
import {AwsClientStub, AwsStub} from './awsClientStub';

Expand All @@ -12,7 +12,7 @@ import {AwsClientStub, AwsStub} from './awsClientStub';
*/
export const mockClient = <TInput extends object, TOutput extends MetadataBearer, TConfiguration>(
client: InstanceOrClassType<Client<TInput, TOutput, TConfiguration>>,
{sandbox}: { sandbox?: SinonSandbox } = {},
{sandbox}: { sandbox?: sinon.SinonSandbox } = {},
): AwsClientStub<Client<TInput, TOutput, TConfiguration>> => {
const instance = isClientInstance(client) ? client : client.prototype;

Expand All @@ -22,7 +22,7 @@ export const mockClient = <TInput extends object, TOutput extends MetadataBearer
}

const sinonSandbox = sandbox || sinon;
const sendStub = sinonSandbox.stub(instance, 'send') as SinonStub<[Command<TInput, any, TOutput, any, any>], Promise<TOutput>>;
const sendStub = sinonSandbox.stub(instance, 'send') as sinon.SinonStub<[Command<TInput, any, TOutput, any, any>], Promise<TOutput>>;

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return new AwsStub<TInput, TOutput, TConfiguration>(instance, sendStub);
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"strict": true,
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"noImplicitAny": true,
"noImplicitReturns": true,
Expand Down