@@ -59,13 +59,79 @@ test("Deserialize Item", () => {
5959 const result = nodes [ 0 ] ;
6060
6161 expect ( result ) . toBeDefined ( ) ;
62- expect ( result ! . prop1 ) . toBe ( "string val" ) ;
63- expect ( result ! . sub ) . toBeDefined ( ) ;
62+ expect ( ( result ! as any ) . prop1 ) . toBe ( "string val" ) ;
63+ expect ( ( result ! as any ) . sub ) . toBeDefined ( ) ;
6464 expect ( result ) . toHaveProperty ( "sub.more" , 10 ) ;
6565 expect ( result ) . toHaveProperty ( "sub.stuff" , "but nested" ) ;
6666 expect ( result ) . toHaveProperty ( "sub.boolprop" , false ) ;
6767 expect ( result ) . toHaveProperty ( "sub.boolpropa" , true ) ;
6868 expect ( result ) . toHaveProperty ( "another prop" , [ "with" , "multiple" , "values" ] ) ;
6969 expect ( result ) . toHaveProperty ( "floatprop" , 4.5 ) ;
7070 expect ( result ) . toHaveProperty ( "intprop" , 90000 ) ;
71+ } ) ;
72+
73+ test ( "Deserialize mdlinfo" , ( ) => {
74+ const doc = parseText ( `"_hr/props/pedestal_button"
75+ {
76+ "general"
77+ {
78+ "name" "_hr/props/pedestal_button"
79+ "filename" "/home/stefan/Projects/PortalRevolution2/game/revolution/models/_hr/props/pedestal_button.mdl"
80+ "id" "1414743113"
81+ "version" "49"
82+ "checksum" "1323378053"
83+ "eye_pos" "0.000000 0.000000 0.000000"
84+ "illum_pos" "0.000000 0.000000 23.486897"
85+ "hull_min" "-12.849852 -12.849851 -0.255160"
86+ "hull_max" "12.849852 12.849851 47.038059"
87+ "bone_count" "3"
88+ "attachment_count" "0"
89+ "surfaceprop" "default"
90+ }
91+ "materials"
92+ {
93+ "0" "pedestal_button_blue"
94+ "1" "pedestal_button_orange"
95+ "2" "pedestal_button"
96+ }
97+ "cdmaterials"
98+ {
99+ "0" "_hr/models/props/"
100+ }
101+ "mdlkeyvalue"
102+ {
103+ "qc_path"
104+ {
105+ "value" "models\\_hr\\props\\pedestal_button\\pedestal_button.qc"
106+ }
107+ }
108+ }` ) ;
109+
110+ const nodes = KvSerializer . deserialize ( doc , { detectArrays : true } ) ;
111+ expect ( nodes ) . toHaveLength ( 1 ) ;
112+
113+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.name" , "_hr/props/pedestal_button" ) ;
114+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.filename" , "/home/stefan/Projects/PortalRevolution2/game/revolution/models/_hr/props/pedestal_button.mdl" ) ;
115+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.id" , 1414743113 ) ;
116+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.version" , 49 ) ;
117+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.checksum" , 1323378053 ) ;
118+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.eye_pos" , "0.000000 0.000000 0.000000" ) ;
119+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.illum_pos" , "0.000000 0.000000 23.486897" ) ;
120+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.hull_min" , "-12.849852 -12.849851 -0.255160" ) ;
121+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.hull_max" , "12.849852 12.849851 47.038059" ) ;
122+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.bone_count" , 3 ) ;
123+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.attachment_count" , 0 ) ;
124+ expect ( nodes [ 0 ] ) . toHaveProperty ( "general.surfaceprop" , "default" ) ;
125+
126+ expect ( Array . isArray ( ( nodes [ 0 ] as any ) . materials ) ) . toBeTruthy ( ) ;
127+ expect ( ( nodes [ 0 ] as any ) . materials ) . toHaveLength ( 3 ) ;
128+ expect ( ( nodes [ 0 ] as any ) . materials [ 0 ] ) . toBe ( "pedestal_button_blue" ) ;
129+ expect ( ( nodes [ 0 ] as any ) . materials [ 1 ] ) . toBe ( "pedestal_button_orange" ) ;
130+ expect ( ( nodes [ 0 ] as any ) . materials [ 2 ] ) . toBe ( "pedestal_button" ) ;
131+
132+ expect ( Array . isArray ( ( nodes [ 0 ] as any ) . cdmaterials ) ) . toBeTruthy ( ) ;
133+ expect ( ( nodes [ 0 ] as any ) . cdmaterials ) . toHaveLength ( 1 ) ;
134+ expect ( ( nodes [ 0 ] as any ) . cdmaterials [ 0 ] ) . toBe ( "_hr/models/props/" ) ;
135+
136+ expect ( nodes [ 0 ] ) . toHaveProperty ( "mdlkeyvalue.qc_path.value" , "models\\_hr\\props\\pedestal_button\\pedestal_button.qc" ) ;
71137} ) ;
0 commit comments