Skip to content

Commit bdf581a

Browse files
committed
Rename helper to assertRejectsWithHardhatError
1 parent 3cf7d90 commit bdf581a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

v-next/hardhat-test-utils/src/hardhat-error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function assertThrowsHardhatError<
4444
assert.fail("Function did not throw any error");
4545
}
4646

47-
export async function assertThrowsHardhatErrorAsync<
47+
export async function assertRejectsWithHardhatError<
4848
ErrorDescriptorT extends ErrorDescriptor,
4949
>(
5050
f: (() => Promise<any>) | Promise<any>,

v-next/hardhat-test-utils/test/hardhat-error.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { HardhatError } from "@ignored/hardhat-vnext-errors";
66
import {
77
assertIsHardhatError,
88
assertThrowsHardhatError,
9-
assertThrowsHardhatErrorAsync,
9+
assertRejectsWithHardhatError,
1010
} from "../src/hardhat-error.js";
1111

1212
describe("HardhatError helpers", () => {
@@ -105,10 +105,10 @@ describe("HardhatError helpers", () => {
105105
});
106106
});
107107

108-
describe("assertThrowsHardhatErrorAsync", () => {
108+
describe("assertRejectsWithHardhatError", () => {
109109
it("should throw if the function doesn't return a promise that rejects", async () => {
110110
await assert.rejects(async () =>
111-
assertThrowsHardhatErrorAsync(
111+
assertRejectsWithHardhatError(
112112
async () => {},
113113
HardhatError.ERRORS.TASK_DEFINITIONS.INVALID_ACTION,
114114
{ action: "foo", task: "bar" },
@@ -118,7 +118,7 @@ describe("HardhatError helpers", () => {
118118

119119
it("should throw the promise that rejects", async () => {
120120
await assert.rejects(async () =>
121-
assertThrowsHardhatErrorAsync(
121+
assertRejectsWithHardhatError(
122122
Promise.resolve(1),
123123
HardhatError.ERRORS.TASK_DEFINITIONS.INVALID_ACTION,
124124
{ action: "foo", task: "bar" },
@@ -128,7 +128,7 @@ describe("HardhatError helpers", () => {
128128

129129
it("asserts the error of the rejection", async () => {
130130
await assert.rejects(() =>
131-
assertThrowsHardhatErrorAsync(
131+
assertRejectsWithHardhatError(
132132
async () => {
133133
throw new HardhatError(
134134
HardhatError.ERRORS.TASK_DEFINITIONS.UNRECOGNIZED_TASK_OPTION,
@@ -141,7 +141,7 @@ describe("HardhatError helpers", () => {
141141
);
142142

143143
await assert.rejects(() =>
144-
assertThrowsHardhatErrorAsync(
144+
assertRejectsWithHardhatError(
145145
Promise.reject(
146146
new HardhatError(
147147
HardhatError.ERRORS.TASK_DEFINITIONS.UNRECOGNIZED_TASK_OPTION,
@@ -153,7 +153,7 @@ describe("HardhatError helpers", () => {
153153
),
154154
);
155155

156-
await assertThrowsHardhatErrorAsync(
156+
await assertRejectsWithHardhatError(
157157
async () => {
158158
throw new HardhatError(
159159
HardhatError.ERRORS.TASK_DEFINITIONS.UNRECOGNIZED_TASK_OPTION,

0 commit comments

Comments
 (0)