mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
refactor(expect): align additional error messages (#5811)
This commit is contained in:
parent
73987a1772
commit
f1d04d6403
@ -103,11 +103,11 @@ export function equal(c: unknown, d: unknown, options?: EqualOptions): boolean {
|
||||
}
|
||||
if (a instanceof WeakMap || b instanceof WeakMap) {
|
||||
if (!(a instanceof WeakMap && b instanceof WeakMap)) return false;
|
||||
throw new TypeError("cannot compare WeakMap instances");
|
||||
throw new TypeError("Cannot compare WeakMap instances");
|
||||
}
|
||||
if (a instanceof WeakSet || b instanceof WeakSet) {
|
||||
if (!(a instanceof WeakSet && b instanceof WeakSet)) return false;
|
||||
throw new TypeError("cannot compare WeakSet instances");
|
||||
throw new TypeError("Cannot compare WeakSet instances");
|
||||
}
|
||||
if (seen.get(a) === b) {
|
||||
return true;
|
||||
|
@ -154,7 +154,7 @@ export function expect<T extends Expected = Expected>(
|
||||
|
||||
if (name === "resolves") {
|
||||
if (!isPromiseLike(value)) {
|
||||
throw new AssertionError("expected value must be Promiselike");
|
||||
throw new AssertionError("Expected value must be PromiseLike");
|
||||
}
|
||||
|
||||
isPromised = true;
|
||||
@ -163,13 +163,13 @@ export function expect<T extends Expected = Expected>(
|
||||
|
||||
if (name === "rejects") {
|
||||
if (!isPromiseLike(value)) {
|
||||
throw new AssertionError("expected value must be a PromiseLike");
|
||||
throw new AssertionError("Expected value must be a PromiseLike");
|
||||
}
|
||||
|
||||
value = value.then(
|
||||
(value) => {
|
||||
throw new AssertionError(
|
||||
`Promise did not reject. resolved to ${value}`,
|
||||
`Promise did not reject: resolved to ${value}`,
|
||||
);
|
||||
},
|
||||
(err) => err,
|
||||
|
@ -10,12 +10,12 @@ Deno.test("expect().resolves.toEqual()", async () => {
|
||||
assertThrows(
|
||||
() => expect(42).resolves.toEqual(42),
|
||||
AssertionError,
|
||||
"expected value must be Promiselike",
|
||||
"Expected value must be PromiseLike",
|
||||
);
|
||||
assertThrows(
|
||||
() => expect(null).resolves.toEqual(42),
|
||||
AssertionError,
|
||||
"expected value must be Promiselike",
|
||||
"Expected value must be PromiseLike",
|
||||
);
|
||||
});
|
||||
|
||||
@ -26,12 +26,12 @@ Deno.test("expect().rejects.toEqual()", async () => {
|
||||
assertThrows(
|
||||
() => expect(42).rejects.toEqual(42),
|
||||
AssertionError,
|
||||
"expected value must be a PromiseLike",
|
||||
"Expected value must be a PromiseLike",
|
||||
);
|
||||
await assertRejects(
|
||||
() => expect(Promise.resolve(42)).rejects.toEqual(42),
|
||||
AssertionError,
|
||||
"Promise did not reject. resolved to 42",
|
||||
"Promise did not reject: resolved to 42",
|
||||
);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user