Skip to content

Commit 5fcb6b4

Browse files
committed
🌿 Add test that fails with current isObjectOf
Prior to v1.16.0, `isObjectOf` would return `true` for an instance.
1 parent 8f1b11a commit 5fcb6b4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

is/factory_test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ import { assertType } from "https://deno.land/[email protected]/testing/types.ts";
99
import { type Equal, stringify } from "./_testutil.ts";
1010
import { type Predicate } from "./type.ts";
1111
import { isOptionalOf } from "./annotation.ts";
12-
import { isArray, isBoolean, isNumber, isString, isUndefined } from "./core.ts";
12+
import {
13+
isArray,
14+
isBoolean,
15+
isFunction,
16+
isNumber,
17+
isString,
18+
isUndefined,
19+
} from "./core.ts";
1320
import is, {
1421
isArrayOf,
1522
isInstanceOf,
@@ -612,6 +619,13 @@ Deno.test("isObjectOf<T>", async (t) => {
612619
"Specify `{ strict: true }` and object have an unknown property",
613620
);
614621
});
622+
await t.step("returns true on T instance", () => {
623+
const date = new Date();
624+
const predObj = {
625+
getFullYear: isFunction,
626+
};
627+
assertEquals(isObjectOf(predObj)(date), true, "Value is not an object");
628+
});
615629
await testWithExamples(
616630
t,
617631
isObjectOf({ a: (_: unknown): _ is unknown => false }),

0 commit comments

Comments
 (0)