Skip to content

Commit ead1121

Browse files
committed
tests: chore - add resetCopy getter/setter intact
1 parent 1803ecb commit ead1121

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

test/service-module/service-module.mutations.test.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,13 +1169,36 @@ describe('Service Module - Mutations', function () {
11691169

11701170
const item1 = {
11711171
_id: 1,
1172-
test: true /*,
1172+
test: true
1173+
}
1174+
store.commit('comics/addItem', item1)
1175+
1176+
// Create a copy and modify it.
1177+
store.commit('comics/createCopy', item1._id)
1178+
const copy = Comic.copiesById[item1._id]
1179+
copy.test = false
1180+
1181+
// Call resetCopy and check that it's back to the original value
1182+
store.commit('comics/resetCopy', item1._id)
1183+
1184+
assert(copy.test === true, 'the copy was reset')
1185+
1186+
clearModels()
1187+
})
1188+
1189+
it.skip('resetCopy with keepCopiesInStore: false and with intact getter/setter', function () {
1190+
const context = makeContext()
1191+
const { Comic, store } = context
1192+
1193+
const item1 = {
1194+
_id: 1,
1195+
test: true,
11731196
get getter() {
11741197
return 'Life is a Joy!'
11751198
},
11761199
set setter(val) {
11771200
this.test = val
1178-
}*/
1201+
}
11791202
}
11801203
store.commit('comics/addItem', item1)
11811204

@@ -1190,9 +1213,9 @@ describe('Service Module - Mutations', function () {
11901213
assert(copy.test === true, 'the copy was reset')
11911214

11921215
// Make sure accessors stayed intact
1193-
//assertGetter(copy, 'getter', 'Life is a Joy!')
1194-
//copy.setter = false
1195-
//assert(copy.test === false, 'the setter is intact')
1216+
assertGetter(copy, 'getter', 'Life is a Joy!')
1217+
copy.setter = false
1218+
assert(copy.test === false, 'the setter is intact')
11961219

11971220
clearModels()
11981221
})

0 commit comments

Comments
 (0)