Skip to content

Commit f88bfc0

Browse files
committed
test: add triggerRef test for readonly shallowRef
1 parent fafbea7 commit f88bfc0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/reactivity/__tests__/readonly.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import {
88
reactive,
99
readonly,
1010
ref,
11+
shallowRef,
1112
toRaw,
13+
triggerRef,
1214
} from '../src'
1315

1416
/**
@@ -520,3 +522,16 @@ describe('reactivity/readonly', () => {
520522
expect(r.value).toBe(ro)
521523
})
522524
})
525+
526+
test('should able to trigger on triggerRef', () => {
527+
const r = shallowRef({ a: 1 })
528+
const ror = readonly(r)
529+
let dummy
530+
effect(() => {
531+
dummy = ror.value.a
532+
})
533+
r.value.a = 2
534+
expect(dummy).toBe(1)
535+
triggerRef(ror)
536+
expect(dummy).toBe(2)
537+
})

0 commit comments

Comments
 (0)