@@ -42,22 +42,22 @@ function makeContext() {
42
42
context . result = JSON . parse ( JSON . stringify ( context . result ) )
43
43
}
44
44
45
- feathersClient . use ( 'letters' , memory ( ) )
45
+ feathersClient . use ( 'letters' , memory ( ) )
46
46
47
47
const lettersService = feathersClient . service ( 'letters' )
48
48
49
49
// Setup hooks on letters service to simulate toJSON serialization that occurs
50
50
// with a remote API request.
51
51
lettersService . hooks ( {
52
52
before : {
53
- create : [ serialize ] ,
54
- update : [ serialize ] ,
55
- patch : [ serialize ]
53
+ create : [ serialize ] ,
54
+ update : [ serialize ] ,
55
+ patch : [ serialize ]
56
56
} ,
57
57
after : {
58
- create : [ deserialize ] ,
59
- patch : [ deserialize ] ,
60
- update : [ deserialize ]
58
+ create : [ deserialize ] ,
59
+ patch : [ deserialize ] ,
60
+ update : [ deserialize ]
61
61
}
62
62
} )
63
63
@@ -129,43 +129,45 @@ function makeContext() {
129
129
130
130
export { makeContext }
131
131
132
- describe ( 'Models - Methods' , function ( ) {
132
+ describe ( 'Models - Methods' , function ( ) {
133
133
beforeEach ( ( ) => {
134
134
clearModels ( )
135
135
} )
136
136
137
- it ( 'Model.find is a function' , function ( ) {
137
+ it ( 'Model.find is a function' , function ( ) {
138
138
const { Task } = makeContext ( )
139
139
140
140
assert ( typeof Task . find === 'function' )
141
141
} )
142
142
143
- it ( 'Model.find returns a Promise' , function ( ) {
143
+ it ( 'Model.find returns a Promise' , function ( ) {
144
144
const { Task } = makeContext ( )
145
145
const result = Task . find ( )
146
146
assert ( typeof result . then !== 'undefined' )
147
- result . catch ( err => { /* noop -- prevents UnhandledPromiseRejectionWarning */ } )
147
+ result . catch ( err => {
148
+ /* noop -- prevents UnhandledPromiseRejectionWarning */
149
+ } )
148
150
} )
149
151
150
- it ( 'Model.findInStore' , function ( ) {
152
+ it ( 'Model.findInStore' , function ( ) {
151
153
const { Task } = makeContext ( )
152
154
153
155
assert ( typeof Task . findInStore === 'function' )
154
156
} )
155
157
156
- it ( 'Model.get' , function ( ) {
158
+ it ( 'Model.get' , function ( ) {
157
159
const { Task } = makeContext ( )
158
160
159
161
assert ( typeof Task . get === 'function' )
160
162
} )
161
163
162
- it ( 'Model.getFromStore' , function ( ) {
164
+ it ( 'Model.getFromStore' , function ( ) {
163
165
const { Task } = makeContext ( )
164
166
165
167
assert ( typeof Task . getFromStore === 'function' )
166
168
} )
167
169
168
- it ( 'allows listening to Feathers events on Model' , function ( done ) {
170
+ it ( 'allows listening to Feathers events on Model' , function ( done ) {
169
171
const { Letter } = makeContext ( )
170
172
171
173
Letter . on ( 'created' , data => {
@@ -180,7 +182,7 @@ describe('Models - Methods', function () {
180
182
} ) . save ( )
181
183
} )
182
184
183
- it ( 'instance.save calls create with correct arguments' , function ( ) {
185
+ it ( 'instance.save calls create with correct arguments' , function ( ) {
184
186
const { Task } = makeContext ( )
185
187
const task = new Task ( { test : true } )
186
188
@@ -197,7 +199,7 @@ describe('Models - Methods', function () {
197
199
task . save ( )
198
200
} )
199
201
200
- it ( 'instance.save passes params to create' , function ( ) {
202
+ it ( 'instance.save passes params to create' , function ( ) {
201
203
const { Task } = makeContext ( )
202
204
const task = new Task ( { test : true } )
203
205
let called = false
@@ -214,7 +216,7 @@ describe('Models - Methods', function () {
214
216
assert ( called , 'create should have been called' )
215
217
} )
216
218
217
- it ( 'instance.save passes params to patch' , function ( ) {
219
+ it ( 'instance.save passes params to patch' , function ( ) {
218
220
const { Todo } = makeContext ( )
219
221
const todo = new Todo ( { id : 1 , test : true } )
220
222
let called = false
@@ -231,7 +233,7 @@ describe('Models - Methods', function () {
231
233
assert ( called , 'patch should have been called' )
232
234
} )
233
235
234
- it ( 'instance.save passes params to update' , function ( ) {
236
+ it ( 'instance.save passes params to update' , function ( ) {
235
237
const { Task } = makeContext ( )
236
238
Task . preferUpdate = true
237
239
@@ -250,7 +252,7 @@ describe('Models - Methods', function () {
250
252
assert ( called , 'update should have been called' )
251
253
} )
252
254
253
- it ( 'instance.remove works with temp records' , function ( ) {
255
+ it ( 'instance.remove works with temp records' , function ( ) {
254
256
const { Task, store } = makeContext ( )
255
257
const task = new Task ( { test : true } )
256
258
const tempId = task . __id
@@ -261,28 +263,48 @@ describe('Models - Methods', function () {
261
263
assert ( ! store . state . tasks . tempsById [ tempId ] , 'temp was removed' )
262
264
} )
263
265
264
- it . skip ( 'instance.remove removes cloned records from the store' , function ( ) { } )
265
- it . skip ( 'instance.remove removes cloned records from the Model.copiesById' , function ( ) { } )
266
- it . skip ( 'removes clone and original upon calling clone.remove()' , function ( ) { } )
266
+ it . skip ( 'instance.remove removes cloned records from the store' , function ( ) { } )
267
+ it . skip ( 'instance.remove removes cloned records from the Model.copiesById' , function ( ) { } )
268
+ it . skip ( 'removes clone and original upon calling clone.remove()' , function ( ) { } )
267
269
268
- it ( 'instance methods still available in store data after updateItem mutation (or socket event)' , async function ( ) {
270
+ it ( 'instance methods still available in store data after updateItem mutation (or socket event)' , async function ( ) {
269
271
const { Letter, store, lettersService } = makeContext ( )
270
272
let letter = new Letter ( { name : 'Garmadon' , age : 1025 } )
271
273
272
274
letter = await letter . save ( )
273
275
274
- assert . equal ( typeof letter . save , 'function' , 'saved instance has a save method' )
276
+ assert . equal (
277
+ typeof letter . save ,
278
+ 'function' ,
279
+ 'saved instance has a save method'
280
+ )
275
281
276
- store . commit ( 'letters/updateItem' , { id : letter . id , name : 'Garmadon / Dad' , age : 1026 } )
282
+ store . commit ( 'letters/updateItem' , {
283
+ id : letter . id ,
284
+ name : 'Garmadon / Dad' ,
285
+ age : 1026
286
+ } )
277
287
278
- const letter2 = new Letter ( { id : letter . id , name : 'Just Garmadon' , age : 1027 } )
288
+ const letter2 = new Letter ( {
289
+ id : letter . id ,
290
+ name : 'Just Garmadon' ,
291
+ age : 1027
292
+ } )
279
293
280
- assert . equal ( typeof letter2 . save , 'function' , 'new instance has a save method' )
294
+ assert . equal (
295
+ typeof letter2 . save ,
296
+ 'function' ,
297
+ 'new instance has a save method'
298
+ )
281
299
} )
282
300
283
- it ( 'Dates remain as dates after changes' , async function ( ) {
301
+ it ( 'Dates remain as dates after changes' , async function ( ) {
284
302
const { Letter, store, lettersService } = makeContext ( )
285
- let letter = new Letter ( { name : 'Garmadon' , age : 1025 , createdAt : new Date ( ) . toString ( ) } )
303
+ let letter = new Letter ( {
304
+ name : 'Garmadon' ,
305
+ age : 1025 ,
306
+ createdAt : new Date ( ) . toString ( )
307
+ } )
286
308
287
309
assert ( isDate ( letter . createdAt ) , 'createdAt should be a date' )
288
310
@@ -293,7 +315,7 @@ describe('Models - Methods', function () {
293
315
assert ( isDate ( letter . createdAt ) , 'createdAt should be a date' )
294
316
} )
295
317
296
- it ( 'instance.toJSON' , function ( ) {
318
+ it ( 'instance.toJSON' , function ( ) {
297
319
const { Task } = makeContext ( )
298
320
const task = new Task ( { id : 1 , test : true } )
299
321
0 commit comments