File tree 1 file changed +23
-0
lines changed
tests/warp-drive__schema-record/tests/reads
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ interface User {
19
19
netWorth : number ;
20
20
coolometer : number ;
21
21
rank : number ;
22
+ bestFriend ?: User ;
22
23
}
23
24
24
25
module ( 'Reads | basic fields' , function ( hooks ) {
@@ -192,4 +193,26 @@ module('Reads | basic fields', function (hooks) {
192
193
assert . strictEqual ( resource . attributes ?. coolometer , '100.000' , 'resource cache value for coolometer is correct' ) ;
193
194
assert . strictEqual ( resource . attributes ?. rank , '0' , 'resource cache value for rank is correct' ) ;
194
195
} ) ;
196
+
197
+ test ( 'user record is immutable without calling checkout' , function ( assert ) {
198
+ const store = this . owner . lookup ( 'service:store' ) as Store ;
199
+ const { schema } = store ;
200
+ registerDerivations ( schema ) ;
201
+
202
+ schema . registerResource (
203
+ withDefaults ( {
204
+ type : 'user' ,
205
+ fields : [
206
+ { name : 'name' , kind : 'field' } ,
207
+ ] ,
208
+ } )
209
+ ) ;
210
+
211
+ const record = store . createRecord ( 'user' , { name : 'Rey Skybarker' } ) as User ;
212
+
213
+ assert . ok ( record , 'record is created' ) ;
214
+ assert . throws ( ( ) => {
215
+ record . name = 'Rey Skywalker' ;
216
+ } , / E r r o r : C a n n o t s e t n a m e o n u s e r b e c a u s e t h e r e c o r d i s n o t e d i t a b l e / ) ;
217
+ } ) ;
195
218
} ) ;
You can’t perform that action at this time.
0 commit comments