Skip to content

Commit 1786b57

Browse files
committed
lnit cleanup
1 parent a7fc033 commit 1786b57

File tree

1 file changed

+53
-31
lines changed

1 file changed

+53
-31
lines changed

test/service-module/model-methods.test.ts

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ function makeContext() {
4242
context.result = JSON.parse(JSON.stringify(context.result))
4343
}
4444

45-
feathersClient.use( 'letters', memory() )
45+
feathersClient.use('letters', memory())
4646

4747
const lettersService = feathersClient.service('letters')
4848

4949
// Setup hooks on letters service to simulate toJSON serialization that occurs
5050
// with a remote API request.
5151
lettersService.hooks({
5252
before: {
53-
create: [ serialize ],
54-
update: [ serialize ],
55-
patch: [ serialize ]
53+
create: [serialize],
54+
update: [serialize],
55+
patch: [serialize]
5656
},
5757
after: {
58-
create: [ deserialize ],
59-
patch: [ deserialize ],
60-
update: [ deserialize ]
58+
create: [deserialize],
59+
patch: [deserialize],
60+
update: [deserialize]
6161
}
6262
})
6363

@@ -129,43 +129,45 @@ function makeContext() {
129129

130130
export { makeContext }
131131

132-
describe('Models - Methods', function () {
132+
describe('Models - Methods', function() {
133133
beforeEach(() => {
134134
clearModels()
135135
})
136136

137-
it('Model.find is a function', function () {
137+
it('Model.find is a function', function() {
138138
const { Task } = makeContext()
139139

140140
assert(typeof Task.find === 'function')
141141
})
142142

143-
it('Model.find returns a Promise', function () {
143+
it('Model.find returns a Promise', function() {
144144
const { Task } = makeContext()
145145
const result = Task.find()
146146
assert(typeof result.then !== 'undefined')
147-
result.catch(err => { /* noop -- prevents UnhandledPromiseRejectionWarning */})
147+
result.catch(err => {
148+
/* noop -- prevents UnhandledPromiseRejectionWarning */
149+
})
148150
})
149151

150-
it('Model.findInStore', function () {
152+
it('Model.findInStore', function() {
151153
const { Task } = makeContext()
152154

153155
assert(typeof Task.findInStore === 'function')
154156
})
155157

156-
it('Model.get', function () {
158+
it('Model.get', function() {
157159
const { Task } = makeContext()
158160

159161
assert(typeof Task.get === 'function')
160162
})
161163

162-
it('Model.getFromStore', function () {
164+
it('Model.getFromStore', function() {
163165
const { Task } = makeContext()
164166

165167
assert(typeof Task.getFromStore === 'function')
166168
})
167169

168-
it('allows listening to Feathers events on Model', function (done) {
170+
it('allows listening to Feathers events on Model', function(done) {
169171
const { Letter } = makeContext()
170172

171173
Letter.on('created', data => {
@@ -180,7 +182,7 @@ describe('Models - Methods', function () {
180182
}).save()
181183
})
182184

183-
it('instance.save calls create with correct arguments', function () {
185+
it('instance.save calls create with correct arguments', function() {
184186
const { Task } = makeContext()
185187
const task = new Task({ test: true })
186188

@@ -197,7 +199,7 @@ describe('Models - Methods', function () {
197199
task.save()
198200
})
199201

200-
it('instance.save passes params to create', function () {
202+
it('instance.save passes params to create', function() {
201203
const { Task } = makeContext()
202204
const task = new Task({ test: true })
203205
let called = false
@@ -214,7 +216,7 @@ describe('Models - Methods', function () {
214216
assert(called, 'create should have been called')
215217
})
216218

217-
it('instance.save passes params to patch', function () {
219+
it('instance.save passes params to patch', function() {
218220
const { Todo } = makeContext()
219221
const todo = new Todo({ id: 1, test: true })
220222
let called = false
@@ -231,7 +233,7 @@ describe('Models - Methods', function () {
231233
assert(called, 'patch should have been called')
232234
})
233235

234-
it('instance.save passes params to update', function () {
236+
it('instance.save passes params to update', function() {
235237
const { Task } = makeContext()
236238
Task.preferUpdate = true
237239

@@ -250,7 +252,7 @@ describe('Models - Methods', function () {
250252
assert(called, 'update should have been called')
251253
})
252254

253-
it('instance.remove works with temp records', function () {
255+
it('instance.remove works with temp records', function() {
254256
const { Task, store } = makeContext()
255257
const task = new Task({ test: true })
256258
const tempId = task.__id
@@ -261,28 +263,48 @@ describe('Models - Methods', function () {
261263
assert(!store.state.tasks.tempsById[tempId], 'temp was removed')
262264
})
263265

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() {})
267269

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() {
269271
const { Letter, store, lettersService } = makeContext()
270272
let letter = new Letter({ name: 'Garmadon', age: 1025 })
271273

272274
letter = await letter.save()
273275

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+
)
275281

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+
})
277287

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+
})
279293

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+
)
281299
})
282300

283-
it('Dates remain as dates after changes', async function () {
301+
it('Dates remain as dates after changes', async function() {
284302
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+
})
286308

287309
assert(isDate(letter.createdAt), 'createdAt should be a date')
288310

@@ -293,7 +315,7 @@ describe('Models - Methods', function () {
293315
assert(isDate(letter.createdAt), 'createdAt should be a date')
294316
})
295317

296-
it('instance.toJSON', function () {
318+
it('instance.toJSON', function() {
297319
const { Task } = makeContext()
298320
const task = new Task({ id: 1, test: true })
299321

0 commit comments

Comments
 (0)