|
@@ -439,7 +439,35 @@ describe('denormalizeEntity', () => {
|
|
|
oneToOneRelation: 99,
|
|
oneToOneRelation: 99,
|
|
|
oneToManyRelation: [123, 124, 125]
|
|
oneToManyRelation: [123, 124, 125]
|
|
|
}))
|
|
}))
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test('should handle relations with empty values', () => {
|
|
|
|
|
+ const data = {
|
|
|
|
|
+ id: 7351,
|
|
|
|
|
+ name: null,
|
|
|
|
|
+ oneToOneRelation: null,
|
|
|
|
|
+ oneToManyRelation: []
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ //@ts-ignore
|
|
|
|
|
+ HydraNormalizer.getIriEncodedFields = vi.fn(
|
|
|
|
|
+ (entity) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ oneToOneRelation: DummyApiChild,
|
|
|
|
|
+ oneToManyRelation: DummyApiChild
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ //@ts-ignore
|
|
|
|
|
+ const result = HydraNormalizer.denormalizeEntity(DummyApiModel, data)
|
|
|
|
|
+
|
|
|
|
|
+ expect(result).toStrictEqual(new DummyApiModel({
|
|
|
|
|
+ id: 7351,
|
|
|
|
|
+ name: null,
|
|
|
|
|
+ oneToOneRelation: null,
|
|
|
|
|
+ oneToManyRelation: []
|
|
|
|
|
+ }))
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|