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