@@ -21,7 +21,7 @@ describe("ID Map", () => {
21
21
22
22
fetchMock . get (
23
23
"http://example.com/api/v1/authors/1" ,
24
- responsePayload ( ' John' )
24
+ responsePayload ( " John" )
25
25
)
26
26
27
27
fetchMock . delete ( "http://example.com/api/v1/authors/1" , {
@@ -57,24 +57,24 @@ describe("ID Map", () => {
57
57
it ( "is added to the ID map" , async ( ) => {
58
58
let { data } = await Author . find ( 1 )
59
59
let stored = ApplicationRecord . store . data
60
- expect ( Object . keys ( stored ) [ 0 ] ) . to . eq ( ' authors-1' )
61
- expect ( stored [ ' authors-1' ] ) . to . deep . eq ( data . attributes )
60
+ expect ( Object . keys ( stored ) [ 0 ] ) . to . eq ( " authors-1" )
61
+ expect ( stored [ " authors-1" ] ) . to . deep . eq ( data . attributes )
62
62
} )
63
63
64
64
it ( "syncs with id map" , async ( ) => {
65
65
let author1 = ( await Author . find ( 1 ) ) . data
66
- author1 . firstName = ' updated'
66
+ author1 . firstName = " updated"
67
67
let author2 = ( await Author . find ( 1 ) ) . data
68
- expect ( author1 . firstName ) . to . eq ( ' John' )
68
+ expect ( author1 . firstName ) . to . eq ( " John" )
69
69
} )
70
70
71
71
describe ( "when syncing, then unlistening" , ( ) => {
72
72
it ( "no longer syncs with id map" , async ( ) => {
73
73
let author1 = ( await Author . find ( 1 ) ) . data
74
- author1 . firstName = ' updated'
74
+ author1 . firstName = " updated"
75
75
author1 . unlisten ( )
76
76
let author2 = ( await Author . find ( 1 ) ) . data
77
- expect ( author1 . firstName ) . to . eq ( ' updated' )
77
+ expect ( author1 . firstName ) . to . eq ( " updated" )
78
78
} )
79
79
} )
80
80
@@ -89,7 +89,7 @@ describe("ID Map", () => {
89
89
// we wouldn't want the user typing in the form to update the grid,
90
90
// until the form was saved.
91
91
it ( "syncs multiple instances" , async ( ) => {
92
- fetchMock . put ( "http://example.com/api/v1/authors/1" , {
92
+ fetchMock . patch ( "http://example.com/api/v1/authors/1" , {
93
93
data : {
94
94
id : "1" ,
95
95
type : "authors" ,
@@ -105,17 +105,17 @@ describe("ID Map", () => {
105
105
let author2 = response . data
106
106
107
107
// not synced prior to save
108
- author1 . firstName = ' updated'
109
- expect ( author2 . firstName ) . to . not . eq ( ' updated' )
108
+ author1 . firstName = " updated"
109
+ expect ( author2 . firstName ) . to . not . eq ( " updated" )
110
110
111
111
await author1 . save ( )
112
112
113
113
// now synced after save
114
- expect ( author2 . firstName ) . to . eq ( ' updated' )
114
+ expect ( author2 . firstName ) . to . eq ( " updated" )
115
115
116
116
// now back to unsynced
117
- author1 . firstName = ' updated again'
118
- expect ( author2 . firstName ) . to . eq ( ' updated' )
117
+ author1 . firstName = " updated again"
118
+ expect ( author2 . firstName ) . to . eq ( " updated" )
119
119
} )
120
120
} )
121
121
@@ -142,48 +142,48 @@ describe("ID Map", () => {
142
142
} )
143
143
} )
144
144
145
- describe ( ' and associated to a hasMany relationship' , ( ) => {
145
+ describe ( " and associated to a hasMany relationship" , ( ) => {
146
146
let book : Book
147
147
let author : Author
148
148
149
149
beforeEach ( ( ) => {
150
- book = new Book ( { id : 1 , title : ' original' } )
150
+ book = new Book ( { id : 1 , title : " original" } )
151
151
book . isPersisted = true
152
152
author = new Author ( { id : 1 , books : [ book ] } )
153
153
} )
154
154
155
155
it ( "is also updated within the relationship" , async ( ) => {
156
- expect ( author . books [ 0 ] . title ) . to . eq ( ' original' )
156
+ expect ( author . books [ 0 ] . title ) . to . eq ( " original" )
157
157
let { data } = await Book . find ( 1 )
158
- expect ( data . title ) . to . eq ( ' updated' )
159
- expect ( author . books [ 0 ] . title ) . to . eq ( ' updated' )
158
+ expect ( data . title ) . to . eq ( " updated" )
159
+ expect ( author . books [ 0 ] . title ) . to . eq ( " updated" )
160
160
} )
161
161
} )
162
162
163
- describe ( ' and associated to a belongsTo relationship' , ( ) => {
163
+ describe ( " and associated to a belongsTo relationship" , ( ) => {
164
164
let book : Book
165
165
let author : Author
166
166
167
167
beforeEach ( ( ) => {
168
- author = new Author ( { id : 1 , firstName : ' original' } )
168
+ author = new Author ( { id : 1 , firstName : " original" } )
169
169
author . isPersisted = true
170
170
book = new Book ( { id : 1 , author } )
171
171
book . isPersisted = true
172
172
} )
173
173
174
174
it ( "is also updated within the relationship" , async ( ) => {
175
- expect ( book . author . firstName ) . to . eq ( ' original' )
175
+ expect ( book . author . firstName ) . to . eq ( " original" )
176
176
await Author . find ( 1 )
177
- expect ( book . author . firstName ) . to . eq ( ' John' )
177
+ expect ( book . author . firstName ) . to . eq ( " John" )
178
178
} )
179
179
} )
180
180
181
- describe ( ' and associated to a hasOne relationship' , ( ) => {
181
+ describe ( " and associated to a hasOne relationship" , ( ) => {
182
182
let author : Author
183
183
let bio : Bio
184
184
185
185
beforeEach ( ( ) => {
186
- bio = new Bio ( { id : 1 , description : ' original' } )
186
+ bio = new Bio ( { id : 1 , description : " original" } )
187
187
bio . isPersisted = true
188
188
author = new Author ( { id : 1 , bio } )
189
189
author . isPersisted = true
@@ -199,14 +199,14 @@ describe("ID Map", () => {
199
199
200
200
describe ( "when destroyed via sideposting" , ( ) => {
201
201
beforeEach ( async ( ) => {
202
- fetchMock . put ( "http://example.com/api/v1/authors/1" , {
202
+ fetchMock . patch ( "http://example.com/api/v1/authors/1" , {
203
203
data : {
204
204
id : "1" ,
205
205
type : "authors"
206
206
}
207
207
} )
208
208
209
- fetchMock . put ( "http://example.com/api/books/1" , {
209
+ fetchMock . patch ( "http://example.com/api/books/1" , {
210
210
data : {
211
211
id : "1" ,
212
212
type : "books"
@@ -224,7 +224,7 @@ describe("ID Map", () => {
224
224
author = new Author ( { id : 1 , books : [ book ] } )
225
225
author . isPersisted = true
226
226
book . isMarkedForDestruction = true
227
- await author . save ( { with : ' books' } )
227
+ await author . save ( { with : " books" } )
228
228
} )
229
229
230
230
it ( "is removed from the ID map + relationship" , async ( ) => {
@@ -244,7 +244,7 @@ describe("ID Map", () => {
244
244
book = new Book ( { id : 1 , author } )
245
245
book . isPersisted = true
246
246
author . isMarkedForDestruction = true
247
- await book . save ( { with : ' author' } )
247
+ await book . save ( { with : " author" } )
248
248
} )
249
249
250
250
it ( "is removed from the ID map" , async ( ) => {
@@ -264,7 +264,7 @@ describe("ID Map", () => {
264
264
author = new Author ( { id : 1 , bio } )
265
265
author . isPersisted = true
266
266
bio . isMarkedForDestruction = true
267
- await author . save ( { with : ' bio' } )
267
+ await author . save ( { with : " bio" } )
268
268
} )
269
269
270
270
it ( "is removed from the ID map" , async ( ) => {
@@ -277,14 +277,14 @@ describe("ID Map", () => {
277
277
278
278
describe ( "when disassociated via sideposting" , ( ) => {
279
279
beforeEach ( async ( ) => {
280
- fetchMock . put ( "http://example.com/api/v1/authors/1" , {
280
+ fetchMock . patch ( "http://example.com/api/v1/authors/1" , {
281
281
data : {
282
282
id : "1" ,
283
283
type : "authors"
284
284
}
285
285
} )
286
286
287
- fetchMock . put ( "http://example.com/api/books/1" , {
287
+ fetchMock . patch ( "http://example.com/api/books/1" , {
288
288
data : {
289
289
id : "1" ,
290
290
type : "books"
@@ -302,7 +302,7 @@ describe("ID Map", () => {
302
302
author = new Author ( { id : 1 , books : [ book ] } )
303
303
author . isPersisted = true
304
304
book . isMarkedForDisassociation = true
305
- await author . save ( { with : ' books' } )
305
+ await author . save ( { with : " books" } )
306
306
} )
307
307
308
308
it ( "is still in the store, but removed from the relation" , async ( ) => {
@@ -322,7 +322,7 @@ describe("ID Map", () => {
322
322
book = new Book ( { id : 1 , author } )
323
323
book . isPersisted = true
324
324
author . isMarkedForDisassociation = true
325
- await book . save ( { with : ' author' } ) || this
325
+ ; ( await book . save ( { with : " author" } ) ) || this
326
326
} )
327
327
328
328
it ( "is still in the store, but removed from the relation" , async ( ) => {
@@ -342,7 +342,7 @@ describe("ID Map", () => {
342
342
author = new Author ( { id : 1 , bio } )
343
343
author . isPersisted = true
344
344
bio . isMarkedForDisassociation = true
345
- await author . save ( { with : ' bio' } )
345
+ await author . save ( { with : " bio" } )
346
346
} )
347
347
348
348
it ( "is still in the store, but removed from the relation" , async ( ) => {
@@ -361,27 +361,27 @@ describe("ID Map", () => {
361
361
expect ( ApplicationRecord . store . count ) . to . eq ( 0 )
362
362
} )
363
363
364
- describe ( ' and associated to a hasMany relationship' , ( ) => {
364
+ describe ( " and associated to a hasMany relationship" , ( ) => {
365
365
let book : Book
366
366
let author : Author
367
367
368
368
beforeEach ( ( ) => {
369
369
author = new Author ( { id : 1 } )
370
370
author . isPersisted = true
371
- book = new Book ( { id : 1 } )
371
+ book = new Book ( { id : 1 } )
372
372
book . isPersisted = true
373
373
author . books = [ book ]
374
374
} )
375
375
376
- it ( ' is no longer returned in the relationship' , async ( ) => {
376
+ it ( " is no longer returned in the relationship" , async ( ) => {
377
377
expect ( author . books . length ) . to . eq ( 1 )
378
378
await book . destroy ( )
379
379
expect ( ApplicationRecord . store . find ( book ) ) . to . eq ( undefined )
380
380
expect ( author . books . length ) . to . eq ( 0 )
381
381
} )
382
382
} )
383
383
384
- describe ( ' and associated to a belongsTo relationship' , ( ) => {
384
+ describe ( " and associated to a belongsTo relationship" , ( ) => {
385
385
let author : Author
386
386
let book : Book
387
387
@@ -392,14 +392,14 @@ describe("ID Map", () => {
392
392
book . isPersisted = true
393
393
} )
394
394
395
- it ( ' is no longer returned in the relationship' , async ( ) => {
395
+ it ( " is no longer returned in the relationship" , async ( ) => {
396
396
expect ( book . author ) . to . not . eq ( undefined )
397
397
await author . destroy ( )
398
398
expect ( book . author ) . to . eq ( undefined )
399
399
} )
400
400
} )
401
401
402
- describe ( ' and associated to a hasOne relationship' , ( ) => {
402
+ describe ( " and associated to a hasOne relationship" , ( ) => {
403
403
let author : Author
404
404
let bio : Bio
405
405
@@ -410,11 +410,11 @@ describe("ID Map", () => {
410
410
author . isPersisted = true
411
411
} )
412
412
413
- it ( ' is no longer returned in the relationship' , async ( ) => {
413
+ it ( " is no longer returned in the relationship" , async ( ) => {
414
414
expect ( author . bio ) . to . not . eq ( undefined )
415
415
await bio . destroy ( )
416
416
expect ( author . bio ) . to . eq ( undefined )
417
417
} )
418
418
} )
419
419
} )
420
- } )
420
+ } )
0 commit comments