@@ -307,8 +307,8 @@ describe("Definition Tests", () => {
307307 } ) ;
308308
309309 const state = new State ( ) ;
310- assert . ok ( state . entity1 === undefined ) ;
311- assert . ok ( state . entity2 === undefined ) ;
310+ assert . ok ( state . entity1 instanceof Entity ) ;
311+ assert . ok ( state . entity2 instanceof Entity ) ;
312312
313313 assert . ok ( state . map instanceof MapSchema ) ;
314314 assert . strictEqual ( state . map . size , 0 ) ;
@@ -320,6 +320,8 @@ describe("Definition Tests", () => {
320320 assert . strictEqual ( state . array2 . length , 0 ) ;
321321
322322 const state2 = new State ( ) ;
323+ assert . ok ( state . entity1 !== state2 . entity1 ) ;
324+ assert . ok ( state . entity2 !== state2 . entity2 ) ;
323325 assert . ok ( state . map !== state2 . map ) ;
324326 assert . ok ( state . array1 !== state2 . array1 ) ;
325327 assert . ok ( state . array2 !== state2 . array2 ) ;
@@ -675,7 +677,7 @@ describe("Definition Tests", () => {
675677 } ) ;
676678 } ) ;
677679
678- it ( "should exclude parent props from initialize method" , ( ) => {
680+ it ( "should exclude parent props from initialize method (1) " , ( ) => {
679681 const StatSchema = schema ( {
680682 value : 'number' ,
681683 initialize ( value : number ) {
@@ -710,6 +712,28 @@ describe("Definition Tests", () => {
710712 assert . strictEqual ( entity . stats . get ( 'hp' ) ?. value , 500 ) ;
711713 } ) ;
712714
715+ it ( "should exclude parent props from encode method (2)" , ( ) => {
716+ const AnotherRandomSchema = schema ( {
717+ value : { type : 'string' , default : 'world' , } ,
718+ } ) ;
719+
720+ const RandomSchema = schema ( {
721+ value : { type : 'string' , default : 'hello' , } ,
722+ anotherRandom : AnotherRandomSchema ,
723+ } ) ;
724+
725+ const StatSchema = schema ( {
726+ value : 'number' ,
727+ random : RandomSchema ,
728+ initialize ( value : number ) {
729+ this . value = value ;
730+ } ,
731+ } ) ;
732+
733+ const entity = new StatSchema ( 5 ) ;
734+ console . log ( entity . random . value , entity . random . anotherRandom . value ) ;
735+ } )
736+
713737 } ) ;
714738
715739} ) ;
0 commit comments