Skip to content

Commit 626e6ea

Browse files
committed
remove__isTemp: add test
1 parent 37d01b6 commit 626e6ea

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/service-module/model-temp-ids.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,33 @@ describe('Models - Temp Ids', function() {
373373
})
374374
.catch(done)
375375
})
376+
377+
it('removes __isTemp from temp and clone', function() {
378+
const { makeServicePlugin, BaseModel } = feathersVuex(feathersClient, {
379+
idField: '_id',
380+
serverAlias: 'temp-ids'
381+
})
382+
class Thing extends BaseModel {
383+
public static modelName = 'Thing'
384+
}
385+
const store = new Vuex.Store<RootState>({
386+
plugins: [
387+
makeServicePlugin({
388+
Model: Thing,
389+
service: feathersClient.service('things')
390+
})
391+
]
392+
})
393+
394+
const thing = new Thing()
395+
assert(thing.__isTemp, 'thing has __isTemp')
396+
397+
const clone = thing.clone()
398+
assert(clone.__isTemp, 'Clone also has __isTemp')
399+
400+
store.commit('things/remove__isTemp', thing)
401+
402+
assert(!thing.hasOwnProperty('__isTemp'), '__isTemp was removed from thing')
403+
assert(!clone.hasOwnProperty('__isTemp'), '__isTemp was removed from clone')
404+
})
376405
})

0 commit comments

Comments
 (0)