@@ -5,20 +5,31 @@ import { Component, Watch, Base } from '../../dist'
55
66@Component
77export class Comp extends Base {
8-
8+
99 @Watch ( 'defaultWatchKey' )
10- defaultWatcher ( ) {
10+ defaultWatcher ( ) {
1111 return 'defaultWatcher test value'
1212 }
1313
14- @Watch ( 'fullWatchKey' , {
15- deep :true ,
16- immediate :true ,
17- flush :'post'
14+ @Watch ( 'fullWatchKey' , {
15+ deep : true ,
16+ immediate : true ,
17+ flush : 'post'
1818 } )
19- fullWatcher ( ) {
19+
20+ fullWatcher ( ) {
2021 return 'fullWatcher test value'
2122 }
23+ @Watch ( 'arrayWatchKey' )
24+ arrayWatcher1 ( ) {
25+ return 'arrayWatcher1 value'
26+ }
27+ @Watch ( 'arrayWatchKey' , {
28+ immediate : true
29+ } )
30+ arrayWatcher2 ( ) {
31+ return 'arrayWatcher2 value'
32+ }
2233}
2334const CompContext = Comp as any
2435
@@ -27,16 +38,21 @@ describe('decorator Watch',
2738 it ( 'default' , ( ) => {
2839 expect ( 'function' ) . to . equal ( typeof CompContext ?. watch ?. defaultWatchKey ?. handler )
2940 expect ( 'defaultWatcher test value' ) . to . equal ( CompContext . watch . defaultWatchKey . handler ( ) )
30-
41+
3142 } )
32- it ( 'full option' , ( ) => {
43+ it ( 'full option' , ( ) => {
3344 expect ( 'function' ) . to . equal ( typeof CompContext ?. watch ?. fullWatchKey ?. handler )
3445 expect ( 'fullWatcher test value' ) . to . equal ( CompContext . watch . fullWatchKey . handler ( ) )
3546 expect ( true ) . to . equal ( CompContext . watch . fullWatchKey . deep )
3647 expect ( true ) . to . equal ( CompContext . watch . fullWatchKey . immediate )
3748 expect ( 'post' ) . to . equal ( CompContext . watch . fullWatchKey . flush )
3849 } )
39- it ( 'method' , ( ) => {
50+ it ( 'array' , ( ) => {
51+ expect ( true ) . to . equal ( Array . isArray ( CompContext ?. watch ?. arrayWatchKey ) )
52+ expect ( 'arrayWatcher1 value' ) . to . equal ( CompContext . watch . arrayWatchKey [ 0 ] . handler ( ) )
53+ expect ( true ) . to . equal ( CompContext . watch . arrayWatchKey [ 1 ] . immediate )
54+ } )
55+ it ( 'method' , ( ) => {
4056 expect ( 'function' ) . to . equal ( typeof CompContext ?. methods ?. defaultWatcher )
4157 expect ( 'defaultWatcher test value' ) . to . equal ( CompContext . methods . defaultWatcher ( ) )
4258 } )
0 commit comments