File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/reactivity/__tests__ Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,32 @@ describe('reactivity/ref', () => {
4343 expect ( fn ) . toHaveBeenCalledTimes ( 2 )
4444 } )
4545
46+ it ( 'ref wrapped in reactive should not track internal _value access' , ( ) => {
47+ const a = ref ( 1 )
48+ const b = reactive ( a )
49+ let calls = 0
50+ let dummy
51+
52+ effect ( ( ) => {
53+ calls ++
54+ dummy = b . value // this will observe both b.value and a.value access
55+ } )
56+ expect ( calls ) . toBe ( 1 )
57+ expect ( dummy ) . toBe ( 1 )
58+
59+ // mutating a.value should only trigger effect once
60+ calls = 0
61+ a . value = 3
62+ expect ( calls ) . toBe ( 1 )
63+ expect ( dummy ) . toBe ( 3 )
64+
65+ // mutating b.value should trigger the effect twice. (once for a.value change and once for b.value change)
66+ calls = 0
67+ b . value = 5
68+ expect ( calls ) . toBe ( 2 )
69+ expect ( dummy ) . toBe ( 5 )
70+ } )
71+
4672 it ( 'should make nested properties reactive' , ( ) => {
4773 const a = ref ( {
4874 count : 1 ,
You can’t perform that action at this time.
0 commit comments