@@ -98,26 +98,27 @@ describe("Filter SDK", () => {
9898 expect ( subscriptionInvokeStub . firstCall . args [ 1 ] ) . to . equal ( peerId ) ;
9999 } ) ;
100100
101- it ( "should successfully stop" , async ( ) => {
101+ it ( "should stop and remove handler " , async ( ) => {
102102 const contentTopic2 = "/test/1/waku-filter-2/utf8" ;
103103 const decoder2 = createDecoder (
104104 contentTopic2 ,
105105 createRoutingInfo ( testNetworkconfig , { contentTopic : contentTopic2 } )
106106 ) ;
107- const stopStub = sinon . stub ( Subscription . prototype , "stop" ) ;
108-
107+ const subscriptionStopStub = sinon . stub ( Subscription . prototype , "stop" ) ;
109108 sinon . stub ( Subscription . prototype , "add" ) . resolves ( true ) ;
110109 sinon . stub ( Subscription . prototype , "start" ) ;
111110
112111 await filter . subscribe ( decoder , callback ) ;
113112 await filter . subscribe ( decoder2 , callback ) ;
114113
115- filter . unsubscribeAll ( ) ;
114+ const protocolStopStub = sinon
115+ . stub ( ( filter as any ) [ "protocol" ] , "stop" )
116+ . resolves ( ) ;
116117
117- expect ( stopStub . calledOnce ) . to . be . true ;
118+ await filter . stop ( ) ;
118119
119- const result = await filter . unsubscribe ( decoder ) ;
120- expect ( result ) . to . be . false ;
120+ expect ( subscriptionStopStub . calledOnce ) . to . be . true ;
121+ expect ( protocolStopStub . calledOnce ) . to . be . true ;
121122 } ) ;
122123} ) ;
123124
0 commit comments