@@ -28,38 +28,43 @@ const debounceRef: CustomRefFactory<any> = (track, trigger) => {
28
28
const delay = ( timeout : number ) =>
29
29
new Promise ( ( resolve ) => setTimeout ( resolve , timeout ) )
30
30
31
- test ( 'Mut decorator' , async ( ) => {
32
- class CountComponent extends VueComponent {
33
- @Mut ( ) count = 1
34
- // shallow ref
35
- @Mut ( true ) obj = { count : 1 }
36
- // custom ref
37
- @Mut ( debounceRef ) count1 = 1
31
+ class CountComponent extends VueComponent {
32
+ @Mut ( ) count = 1
33
+ // shallow ref
34
+ @Mut ( true ) obj = { count : 1 }
35
+ // custom ref
36
+ @Mut ( debounceRef ) count1 = 1
38
37
39
- render ( ) {
40
- return (
41
- < div >
42
- < p onClick = { ( ) => this . count ++ } > { this . count } </ p >
43
- < div id = "shallow" onClick = { ( ) => this . obj . count ++ } >
44
- { this . obj . count }
45
- </ div >
46
- < div id = "custom" onClick = { ( ) => this . count1 ++ } >
47
- { this . count1 }
48
- </ div >
38
+ render ( ) {
39
+ return (
40
+ < div >
41
+ < p onClick = { ( ) => this . count ++ } > { this . count } </ p >
42
+ < div id = "shallow" onClick = { ( ) => this . obj . count ++ } >
43
+ { this . obj . count }
49
44
</ div >
50
- )
51
- }
45
+ < div id = "custom" onClick = { ( ) => this . count1 ++ } >
46
+ { this . count1 }
47
+ </ div >
48
+ </ div >
49
+ )
52
50
}
51
+ }
52
+
53
+ test ( 'Mut decorator should work' , async ( ) => {
53
54
// @ts -ignore
54
55
const wrapper = mount ( CountComponent )
55
- const vm = wrapper . vm as unknown as CountComponent
56
56
57
57
const p = wrapper . get ( 'p' )
58
58
expect ( p . text ( ) ) . toContain ( '1' )
59
59
await p . trigger ( 'click' )
60
60
expect ( p . text ( ) ) . toContain ( '2' )
61
+ } )
62
+
63
+ test ( 'mut: shallow ref' , async ( ) => {
64
+ // @ts -ignore
65
+ const wrapper = mount ( CountComponent )
66
+ const vm = wrapper . vm as unknown as CountComponent
61
67
62
- // shallow ref
63
68
const shallow = wrapper . get ( '#shallow' )
64
69
expect ( shallow . text ( ) ) . toContain ( '1' )
65
70
await shallow . trigger ( 'click' )
@@ -69,7 +74,11 @@ test('Mut decorator', async () => {
69
74
await vm . $nextTick ( )
70
75
console . log ( shallow . text ( ) )
71
76
expect ( shallow . text ( ) ) . toContain ( '2' )
77
+ } )
72
78
79
+ test ( 'mut: custom ref' , async ( ) => {
80
+ // @ts -ignore
81
+ const wrapper = mount ( CountComponent )
73
82
// custom ref
74
83
const custom = wrapper . get ( '#custom' )
75
84
expect ( custom . text ( ) ) . toContain ( '1' )
0 commit comments