File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const onReconnecting = [];
88let createClientError = false ;
99let connectError = false ;
1010let subscribeError = false ;
11+ let counter = { } ;
1112
1213const client = {
1314 connect : jest . fn ( ( ) => {
@@ -37,12 +38,28 @@ const client = {
3738 return Promise . resolve ( ) ;
3839 } ) ,
3940 off : jest . fn ( ) ,
41+ get : jest . fn ( ( key ) => {
42+ return counter [ key ] ;
43+ } ) ,
44+ set : jest . fn ( ( key , value ) => {
45+ counter [ key ] = value ;
46+ return "OK" ;
47+ } ) ,
48+ incr : jest . fn ( ( key ) => {
49+ counter [ key ] ++ ;
50+ return counter [ key ] ;
51+ } ) ,
52+ decr : jest . fn ( ( key ) => {
53+ counter [ key ] -- ;
54+ return counter [ key ] ;
55+ } ) ,
4056 subscribe : jest . fn ( ( channel , cb ) => {
4157 if ( subscribeError ) {
4258 subscribeError = false ;
4359 throw new Error ( "subscribe error" ) ;
4460 }
4561 onSubscribe . push ( cb ) ;
62+ return Promise . resolve ( ) ;
4663 } ) ,
4764 sSubscribe : jest . fn ( ) ,
4865 pSubscribe : jest . fn ( ) ,
@@ -55,6 +72,7 @@ const client = {
5572 for ( const on of onSubscribe ) {
5673 on ( message , channel ) ;
5774 }
75+ return Promise . resolve ( ) ;
5876 } ) ,
5977 error : jest . fn ( ( err ) => {
6078 for ( const on of onError ) {
You can’t perform that action at this time.
0 commit comments