Skip to content

Commit 8f61e86

Browse files
committed
test: add instance.remove with clone tests
-> keep it.skip to discuss
1 parent 83a145d commit 8f61e86

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

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

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ function makeContext() {
9898
}
9999
}
100100

101+
class Person extends BaseModel {
102+
public static modelName = 'Person'
103+
public static servicePath: 'persons'
104+
public constructor(data?, options?) {
105+
super(data, options)
106+
}
107+
}
108+
101109
const store = new Vuex.Store<RootState>({
102110
strict: true,
103111
plugins: [
@@ -114,6 +122,12 @@ function makeContext() {
114122
Model: Letter,
115123
servicePath: 'letters',
116124
service: feathersClient.service('letters')
125+
}),
126+
makeServicePlugin({
127+
Model: Person,
128+
servicePath: 'persons',
129+
service: feathersClient.service('persons'),
130+
keepCopiesInStore: true
117131
})
118132
]
119133
})
@@ -122,6 +136,7 @@ function makeContext() {
122136
Task,
123137
Todo,
124138
Letter,
139+
Person,
125140
lettersService,
126141
store
127142
}
@@ -284,8 +299,38 @@ describe('Models - Methods', function () {
284299
assert(!store.state.tasks.tempsById[tempId], 'temp was removed')
285300
})
286301

287-
it.skip('instance.remove removes cloned records from the store', function () {})
288-
it.skip('instance.remove removes cloned records from the Model.copiesById', function () {})
302+
it.skip('instance.remove removes cloned records from the store', function () {
303+
const { Person, store } = makeContext()
304+
const person = new Person({ test: true })
305+
const tempId = person.__id
306+
307+
person.clone()
308+
309+
// @ts-ignore
310+
assert(store.state.persons.copiesById[tempId], 'clone exists')
311+
312+
person.remove()
313+
314+
// @ts-ignore
315+
assert(!store.state.persons.copiesById[tempId], 'clone was removed')
316+
})
317+
318+
it.skip('instance.remove removes cloned records from the Model.copiesById', function () {
319+
const { Task, store } = makeContext()
320+
const task = new Task({ test: true })
321+
const tempId = task.__id
322+
323+
task.clone()
324+
325+
// @ts-ignore
326+
assert(Task.copiesById[tempId], 'clone exists')
327+
328+
task.remove()
329+
330+
// @ts-ignore
331+
assert(!Task.copiesById[tempId], 'clone was removed')
332+
})
333+
289334
it.skip('removes clone and original upon calling clone.remove()', function () {})
290335

291336
it('instance methods still available in store data after updateItem mutation (or socket event)', async function () {

0 commit comments

Comments
 (0)