@@ -98,4 +98,46 @@ Deno.test("isObjectOf<T>", async (t) => {
9898 > ( true ) ;
9999 }
100100 } ) ;
101+
102+ await t . step ( "if 'predObj' has prototype properties" , async ( t ) => {
103+ const prototypeObj = {
104+ a : is . Number ,
105+ b : is . Boolean ,
106+ } ;
107+ // deno-lint-ignore ban-types
108+ const predObj2 = Object . assign ( Object . create ( prototypeObj ) as { } , {
109+ c : is . String ,
110+ } ) ;
111+
112+ await t . step ( "returns true on T object that omits prototype" , ( ) => {
113+ assertEquals ( isObjectOf ( predObj2 ) ( { c : "a" } ) , true ) ;
114+ assertEquals (
115+ isObjectOf ( predObj2 ) ( { c : "a" , d : "ignored" } ) ,
116+ true ,
117+ ) ;
118+ assertEquals (
119+ isObjectOf ( predObj2 ) ( Object . assign ( ( ) => void 0 , { c : "a" } ) ) ,
120+ true ,
121+ ) ;
122+ } ) ;
123+
124+ await t . step ( "returns false on non T object that omits prototype" , ( ) => {
125+ assertEquals ( isObjectOf ( predObj2 ) ( "a" ) , false , "Value is not an object" ) ;
126+ assertEquals (
127+ isObjectOf ( predObj2 ) ( { a : 0 , b : true , c : 1 } ) ,
128+ false ,
129+ "Object have a different type property" ,
130+ ) ;
131+ assertEquals (
132+ isObjectOf ( predObj2 ) ( { a : 0 , b : true } ) ,
133+ false ,
134+ "Object does not have one property" ,
135+ ) ;
136+ assertEquals (
137+ isObjectOf ( { 0 : is . String } ) ( [ "a" ] ) ,
138+ false ,
139+ "Value is not an object" ,
140+ ) ;
141+ } ) ;
142+ } ) ;
101143} ) ;
0 commit comments