@@ -58,6 +58,63 @@ describe('resolveInitialValue', () => {
58
58
} )
59
59
} )
60
60
61
+ test ( 'throws on unknown prop in reference' , ( ) => {
62
+ expect (
63
+ resolveInitialValue (
64
+ schema ,
65
+ { ...example , value : { bestFriend : { _ref : 'grrm' , name : 'GRRM' } } } ,
66
+ { } ,
67
+ mockConfigContext ,
68
+ ) ,
69
+ ) . rejects . toMatchObject ( {
70
+ message :
71
+ 'Template "author" initial value: Disallowed property found in reference: "name" at path "bestFriend"' ,
72
+ } )
73
+ } )
74
+
75
+ test ( 'throws on unknown props in reference' , ( ) => {
76
+ expect (
77
+ resolveInitialValue (
78
+ schema ,
79
+ { ...example , value : { bestFriend : { _ref : 'grrm' , name : 'GRRM' , age : 72 } } } ,
80
+ { } ,
81
+ mockConfigContext ,
82
+ ) ,
83
+ ) . rejects . toMatchObject ( {
84
+ message :
85
+ 'Template "author" initial value: Disallowed properties found in reference: "name", "age" at path "bestFriend"' ,
86
+ } )
87
+ } )
88
+
89
+ test ( 'allows setting known reference properties' , ( ) => {
90
+ expect (
91
+ resolveInitialValue (
92
+ schema ,
93
+ { ...example , value : { bestFriend : { _ref : 'grrm' , _type : 'reference' , _weak : true } } } ,
94
+ { } ,
95
+ mockConfigContext ,
96
+ ) ,
97
+ ) . resolves . toMatchObject ( {
98
+ bestFriend : { _ref : 'grrm' , _type : 'reference' , _weak : true } ,
99
+ } )
100
+ } )
101
+
102
+ test ( 'allows setting _dataset on cross-dataset references' , ( ) => {
103
+ expect (
104
+ resolveInitialValue (
105
+ schema ,
106
+ {
107
+ ...example ,
108
+ value : { bestFriend : { _ref : 'grrm' , _type : 'crossDatasetReference' , _dataset : 'bffs' } } ,
109
+ } ,
110
+ { } ,
111
+ mockConfigContext ,
112
+ ) ,
113
+ ) . resolves . toMatchObject ( {
114
+ bestFriend : { _ref : 'grrm' , _type : 'crossDatasetReference' , _dataset : 'bffs' } ,
115
+ } )
116
+ } )
117
+
61
118
test ( 'should call sync value resolvers' , ( ) => {
62
119
expect (
63
120
resolveInitialValue ( schema , { ...example , value : ( ) => example . value } , { } , mockConfigContext ) ,
0 commit comments