Skip to content

Commit 87c7a0c

Browse files
committed
refactor: use explicit Promise methods in asyncAttempt tests
1 parent 8ed6239 commit 87c7a0c

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

async_attempt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Result } from "./attempt.ts";
1+
import type { Result } from "./attempt.ts";
22

33
export type AsyncResult<T, E> = Promise<Result<T, E>>;
44

async_attempt_test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import { assertEquals } from "@std/assert";
33
import { asyncAttempt } from "./async_attempt.ts";
44

55
test("asyncAttempt should return a Success<T> when the async function is successful", async () => {
6-
const result = await asyncAttempt(async () => 1);
6+
const result = await asyncAttempt(() => Promise.resolve(1));
77
assertEquals(result, [undefined, 1]);
88
});
99

1010
test("asyncAttempt should return a Failure<E> when the async function is failed", async () => {
11-
const result = await asyncAttempt(async () => {
12-
throw "err";
13-
});
11+
const result = await asyncAttempt(() => Promise.reject("err"));
1412
assertEquals(result, ["err", undefined]);
1513
});

0 commit comments

Comments
 (0)