Skip to content

Commit

Permalink
test: add failed test for #498 (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 14, 2021
1 parent e67940f commit e754a63
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/v3/runtime-core/apiWatch.spec.ts
Expand Up @@ -532,6 +532,28 @@ describe('api: watch', () => {
expect(data2.value).toMatchObject([1])
})

// #498
it('watchEffect should not lead to infinite loop when accessing', async () => {
let dummy = 0

const state = reactive({
data: [],
watchVar: 123,
})

watchEffect(() => {
// accessing
state.watchVar
// setting
state.data = []
dummy += 1
})

expect(dummy).toBe(1)
await nextTick()
expect(dummy).toBe(1)
})

it('watching deep ref', async () => {
const count = ref(0)
const double = computed(() => count.value * 2)
Expand Down

0 comments on commit e754a63

Please sign in to comment.