Skip to content

Commit 71d0767

Browse files
committed
update tests
Comments: - ignore readonly ModelStatic props - casts models to `any` since we can't augment for each test
1 parent 24de582 commit 71d0767

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ describe('makeModel / BaseModel', function () {
130130
const { BaseModel, makeServicePlugin } = feathersVuex(feathers, {
131131
serverAlias: 'myApi'
132132
})
133+
//@ts-ignore
133134
BaseModel.modelName = 'TestModel'
134135
const plugin = makeServicePlugin({
135136
servicePath: 'todos',
@@ -220,19 +221,20 @@ describe('makeModel / BaseModel', function () {
220221
plugins: [todosPlugin, tasksPlugin]
221222
})
222223
const { models } = myApi
224+
const anyModels = models as any
223225

224-
assert(models.myApi.Todo === Todo)
225-
assert(!models.theirApi.Todo, `Todo stayed out of the 'theirApi' namespace`)
226-
assert(models.theirApi.Task === Task)
227-
assert(!models.myApi.Task, `Task stayed out of the 'myApi' namespace`)
226+
assert(anyModels.myApi.Todo === Todo)
227+
assert(!anyModels.theirApi.Todo, `Todo stayed out of the 'theirApi' namespace`)
228+
assert(anyModels.theirApi.Task === Task)
229+
assert(!anyModels.myApi.Task, `Task stayed out of the 'myApi' namespace`)
228230

229231
assert.equal(
230-
models.myApi.byServicePath[Todo.servicePath],
232+
anyModels.myApi.byServicePath[Todo.servicePath],
231233
Todo,
232234
'also registered in models.byServicePath'
233235
)
234236
assert.equal(
235-
models.theirApi.byServicePath[Task.servicePath],
237+
anyModels.theirApi.byServicePath[Task.servicePath],
236238
Task,
237239
'also registered in models.byServicePath'
238240
)

test/service-module/model-instance-defaults.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@ describe('Models - Default Values', function() {
322322
public constructor(data?, options?) {
323323
// Pass { merge: false } in the third arg to prevent BaseModel from
324324
// doing its own merge
325-
super(data, options, { merge: false })
325+
super(data, { merge: false })
326326

327327
// Calling merge here overwrites the Class's default location.
328328
// You could also write `this.location = data.location`
329-
return Person.merge(this, data)
329+
Person.merge(this, data)
330330
}
331331
}
332332

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ describe('Models - Methods', function() {
235235

236236
it('instance.save passes params to update', function() {
237237
const { Task } = makeContext()
238+
//@ts-ignore
238239
Task.preferUpdate = true
239240

240241
const task = new Task({ id: 1, test: true })

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ function makeContext() {
188188
class Item extends BaseModel {
189189
public static modelName = 'Item'
190190
public get todos() {
191-
return BaseModel.models.Todo.findInStore({ query: {} }).data
191+
return (BaseModel.models as any).Todo.findInStore({ query: {} }).data
192192
}
193193
public static instanceDefaults() {
194194
return {

test/utils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ describe('Utils', function() {
8484
feathersClient,
8585
{ serverAlias: 'hydrate' }
8686
)
87+
const anyModels = models as any
8788

8889
class User extends BaseModel {
8990
public static modelName = 'User'
@@ -107,7 +108,7 @@ describe('Utils', function() {
107108
store.commit('users/addServerItem')
108109
assert(store.state.users.keyedById['abcdefg'], 'server document added')
109110
assert(store.state.users.keyedById['abcdefg'] instanceof Object, 'server document is pure javascript object')
110-
hydrateApi({ api: models.hydrate })
111+
hydrateApi({ api: anyModels.hydrate })
111112
assert(store.state.users.keyedById['abcdefg'] instanceof User, 'document hydrated')
112113
})
113114

0 commit comments

Comments
 (0)