@@ -28,38 +28,43 @@ const debounceRef: CustomRefFactory<any> = (track, trigger) => {
2828const delay = ( timeout : number ) =>
2929 new Promise ( ( resolve ) => setTimeout ( resolve , timeout ) )
3030
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
3837
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 }
4944 </ div >
50- )
51- }
45+ < div id = "custom" onClick = { ( ) => this . count1 ++ } >
46+ { this . count1 }
47+ </ div >
48+ </ div >
49+ )
5250 }
51+ }
52+
53+ test ( 'Mut decorator should work' , async ( ) => {
5354 // @ts -ignore
5455 const wrapper = mount ( CountComponent )
55- const vm = wrapper . vm as unknown as CountComponent
5656
5757 const p = wrapper . get ( 'p' )
5858 expect ( p . text ( ) ) . toContain ( '1' )
5959 await p . trigger ( 'click' )
6060 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
6167
62- // shallow ref
6368 const shallow = wrapper . get ( '#shallow' )
6469 expect ( shallow . text ( ) ) . toContain ( '1' )
6570 await shallow . trigger ( 'click' )
@@ -69,7 +74,11 @@ test('Mut decorator', async () => {
6974 await vm . $nextTick ( )
7075 console . log ( shallow . text ( ) )
7176 expect ( shallow . text ( ) ) . toContain ( '2' )
77+ } )
7278
79+ test ( 'mut: custom ref' , async ( ) => {
80+ // @ts -ignore
81+ const wrapper = mount ( CountComponent )
7382 // custom ref
7483 const custom = wrapper . get ( '#custom' )
7584 expect ( custom . text ( ) ) . toContain ( '1' )
0 commit comments