1
- import { plainToClass } from "class-transformer" ;
2
- import { Model , Room2D , Room2DPropertiesAbridged } from "dragonfly-schema" ;
3
- import { Face3D } from "honeybee-schema" ;
4
- import * as fs from 'fs' ;
5
- import * as path from 'path' ;
1
+ import { Room2D , Room2DPropertiesAbridged } from "dragonfly-schema" ;
2
+ import { Type , plainToClass , instanceToPlain , Expose , Transform } from 'class-transformer' ;
3
+ test ( 'test room2d simple' , ( ) => {
4
+ const room2d = new Room2D ( ) ;
5
+
6
+ const jsonObj = room2d . toJSON ( ) ;
7
+ const obj = Room2D . fromJS ( jsonObj ) ;
8
+ obj . validate ( ) . catch ( error => {
9
+ expect ( error . message . startsWith ( "Validation failed: floorBoundary should not be null or undefined," ) ) . toBe ( true ) ;
10
+ } ) ;
11
+ } ) ;
6
12
7
13
test ( 'test room2d' , ( ) => {
8
14
const roomData = {
@@ -197,11 +203,12 @@ test('test room2d', () => {
197
203
null
198
204
] ,
199
205
"user_data" : { }
200
- }
206
+ } ;
201
207
const obj = Room2D . fromJS ( roomData ) ;
202
208
expect ( obj . identifier ) . toBe ( "Room_e6ac360b-aaed-4c3b-a130-36b4c2ac9d13-000d1467" ) ;
203
209
expect ( obj . validate ( ) ) . resolves . toBe ( true ) ;
204
210
211
+
205
212
const jsonObj = obj . toJSON ( ) ;
206
213
const prop = jsonObj [ "properties" ] ;
207
214
expect ( prop [ "energy" ] . hasOwnProperty ( "hvac" ) ) . toBe ( false ) ;
@@ -211,7 +218,7 @@ test('test room2d', () => {
211
218
} ) ;
212
219
213
220
test ( 'test room2d2' , ( ) => {
214
- const roomData = {
221
+ const roomData = {
215
222
"type" : "Room2D" ,
216
223
"identifier" : "Room_e6ac360b-aaed-4c3b-a130-36b4c2ac9d13-000d14cc" ,
217
224
"display_name" : "Laundry-104" ,
@@ -271,7 +278,7 @@ test('test room2d2', () => {
271
278
}
272
279
] ,
273
280
"user_data" : { }
274
- }
281
+ } ;
275
282
const obj = Room2D . fromJS ( roomData ) ;
276
283
expect ( obj . identifier ) . toBe ( "Room_e6ac360b-aaed-4c3b-a130-36b4c2ac9d13-000d14cc" ) ;
277
284
expect ( obj . validate ( ) ) . resolves . toBe ( true ) ;
@@ -296,4 +303,5 @@ test('test roomProperty', () => {
296
303
expect ( jsonObj ) . toHaveProperty ( "energy" ) ;
297
304
expect ( jsonObj . hasOwnProperty ( "radiance" ) ) . toBe ( false ) ;
298
305
299
- } ) ;
306
+ } ) ;
307
+
0 commit comments