Skip to content

Commit 617b984

Browse files
committed
test: simpler
1 parent 51a91c0 commit 617b984

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/pinia/__tests__/store.patch.spec.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ describe('store.$patch', () => {
224224
setActivePinia(createPinia())
225225
return defineStore('shallowRef', () => {
226226
const counter = shallowRef({ count: 0 })
227-
const counter2 = shallowRef({ count: 0 })
228-
const counter3 = shallowRef({ count: 0 })
229227
const markedRaw = ref({
230228
marked: markRaw({ count: 0 }),
231229
})
@@ -237,8 +235,6 @@ describe('store.$patch', () => {
237235
return {
238236
markedRaw,
239237
counter,
240-
counter2,
241-
counter3,
242238
nestedCounter,
243239
}
244240
})()
@@ -293,11 +289,11 @@ describe('store.$patch', () => {
293289
const store = useShallowRefStore()
294290
const watcherSpy = vi.fn()
295291

296-
watch(() => store.counter2.count, watcherSpy, { flush: 'sync' })
292+
watch(() => store.counter.count, watcherSpy, { flush: 'sync' })
297293

298294
watcherSpy.mockClear()
299295
store.$patch((state) => {
300-
state.counter2 = { count: state.counter2.count + 1 }
296+
state.counter = { count: state.counter.count + 1 }
301297
})
302298

303299
expect(watcherSpy).toHaveBeenCalledTimes(1)
@@ -307,10 +303,10 @@ describe('store.$patch', () => {
307303
const store = useShallowRefStore()
308304
const watcherSpy = vi.fn()
309305

310-
watch(() => store.counter3.count, watcherSpy, { flush: 'sync' })
306+
watch(() => store.counter.count, watcherSpy, { flush: 'sync' })
311307

312308
watcherSpy.mockClear()
313-
store.counter3 = { count: 3 }
309+
store.counter = { count: 3 }
314310

315311
expect(watcherSpy).toHaveBeenCalledTimes(1)
316312
})
@@ -342,14 +338,14 @@ describe('store.$patch', () => {
342338
const watcherSpy2 = vi.fn()
343339

344340
watch(() => store.counter.count, watcherSpy1, { flush: 'sync' })
345-
watch(() => store.counter2.count, watcherSpy2, { flush: 'sync' })
341+
watch(() => store.nestedCounter.simple, watcherSpy2, { flush: 'sync' })
346342

347343
watcherSpy1.mockClear()
348344
watcherSpy2.mockClear()
349345

350346
store.$patch({
351347
counter: { count: 10 },
352-
counter2: { count: 20 },
348+
nestedCounter: { nested: { count: 0 }, simple: 20 },
353349
})
354350

355351
expect(watcherSpy1).toHaveBeenCalledTimes(1)

0 commit comments

Comments
 (0)