@@ -9,6 +9,53 @@ import { Organization } from '../examples/models/organization';
9
9
import { Panther } from '../examples/models/panther' ;
10
10
import { Zoo } from '../examples/models/zoo' ;
11
11
import { Employee } from '../examples/models/employee' ;
12
+ import { Reflection } from '../src/reflection' ;
13
+
14
+ describe ( 'Reflection' , ( ) => {
15
+ const unknownTarget : any = undefined ;
16
+
17
+ it ( 'getBaseClass should return undefined if there is no target' , ( ) => {
18
+ expect ( Reflection . getBaseClass ( unknownTarget ) ) . toBeUndefined ( ) ;
19
+ } ) ;
20
+
21
+ it ( 'getJsonPropertiesMetadata should return undefined if there is no target' , ( ) => {
22
+ expect ( Reflection . getJsonPropertiesMetadata ( unknownTarget ) ) . toBeUndefined ( ) ;
23
+ } ) ;
24
+
25
+ it ( 'getParamTypes should return undefined if there is no target' , ( ) => {
26
+ expect ( Reflection . getParamTypes ( unknownTarget ) ) . toBeUndefined ( ) ;
27
+ } ) ;
28
+
29
+ it ( 'getJsonObjectMetadata should return undefined if there is no target' , ( ) => {
30
+ expect ( Reflection . getJsonObjectMetadata ( unknownTarget ) ) . toBeUndefined ( ) ;
31
+ } ) ;
32
+
33
+ it ( 'getType should return undefined if there is no target' , ( ) => {
34
+ expect ( Reflection . getType ( unknownTarget , 'test' ) ) . toBeUndefined ( ) ;
35
+ } ) ;
36
+
37
+ it ( 'isJsonObject should return undefined if there is no target' , ( ) => {
38
+ expect ( Reflection . isJsonObject ( unknownTarget ) ) . toBe ( false ) ;
39
+ } ) ;
40
+
41
+ it ( 'setJsonPropertiesMetadata should not define metadata if there is no target' , ( ) => {
42
+ const spy = jest . spyOn ( Reflect , 'defineMetadata' ) ;
43
+ Reflection . setJsonPropertiesMetadata ( { } , unknownTarget ) ;
44
+ expect ( spy ) . toHaveBeenCalledTimes ( 0 ) ;
45
+ } ) ;
46
+
47
+ it ( 'setJsonObject should not define json object if there is no target' , ( ) => {
48
+ const spy = jest . spyOn ( Reflect , 'defineMetadata' ) ;
49
+ Reflection . setJsonObject ( { baseClassNames : [ ] } , unknownTarget ) ;
50
+ expect ( spy ) . toHaveBeenCalledTimes ( 0 ) ;
51
+ } ) ;
52
+
53
+ it ( 'setType should not define type if there is no target' , ( ) => {
54
+ const spy = jest . spyOn ( Reflect , 'defineMetadata' ) ;
55
+ Reflection . setType ( 'test' , unknownTarget , 'test' ) ;
56
+ expect ( spy ) . toHaveBeenCalledTimes ( 0 ) ;
57
+ } ) ;
58
+ } ) ;
12
59
13
60
describe ( 'JsonObject' , ( ) => {
14
61
it ( 'should return no metadata' , ( ) => {
0 commit comments