Skip to content

Commit

Permalink
Add missing parameters for function assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Leutloff committed May 5, 2021
1 parent 465c8fc commit 1f4a7ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/assertions/forFunctions/AssertThatForFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CommonAssertions } from '../forAny/CommonAssertions';
import { FunctionAssertions } from './FunctionAssertions';

/* eslint-disable @typescript-eslint/ban-types */
type AssertThatForFunction = (actual: Function) => {
is: CommonAssertions<Function> & FunctionAssertions & {
not: CommonAssertions<Function> & FunctionAssertions;
type AssertThatForFunction = <TError extends Error = Error>(actual: Function) => {
is: CommonAssertions<Function> & FunctionAssertions<TError> & {
not: CommonAssertions<Function> & FunctionAssertions<TError>;
};
};
/* eslint-enable @typescript-eslint/ban-types */
Expand Down
32 changes: 22 additions & 10 deletions lib/assertions/forFunctions/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,38 @@ import { assertFunctionIsThrowingAsync } from './assertFunctionIsThrowingAsync';
import { FunctionAssertions } from './FunctionAssertions';
import { report } from '../../report';

const getAssertionsForFunction = function (
// eslint-disable-next-line @typescript-eslint/ban-types
const getAssertionsForFunction = function (actual: Function): FunctionAssertions {
actual: Function
): FunctionAssertions {
return {
throwing (): void {
report(assertFunctionIsThrowing(actual));
throwing <TError extends Error = Error>(
expected?: string | RegExp | ((ex: TError) => boolean)
): void {
report(assertFunctionIsThrowing(actual, expected));
},
async throwingAsync (): Promise<void> {
report(await assertFunctionIsThrowingAsync(actual));
async throwingAsync <TError extends Error = Error>(
expected?: string | RegExp | ((ex: TError) => boolean)
): Promise<void> {
report(await assertFunctionIsThrowingAsync(actual, expected));
}
};
};

const getNegatedAssertionsForFunction = function (
// eslint-disable-next-line @typescript-eslint/ban-types
const getNegatedAssertionsForFunction = function (actual: Function): FunctionAssertions {
actual: Function
): FunctionAssertions {
return {
throwing (): void {
report(assertFunctionIsNotThrowing(actual));
throwing <TError extends Error = Error>(
expected?: string | RegExp | ((ex: TError) => boolean)
): void {
report(assertFunctionIsNotThrowing(actual, expected));
},
async throwingAsync (): Promise<void> {
report(await assertFunctionIsNotThrowingAsync(actual));
async throwingAsync <TError extends Error = Error>(
expected?: string | RegExp | ((ex: TError) => boolean)
): Promise<void> {
report(await assertFunctionIsNotThrowingAsync(actual, expected));
}
};
};
Expand Down
Empty file removed test/unit/randomTests.ts
Empty file.

0 comments on commit 1f4a7ba

Please sign in to comment.