11import type { DidResolver } from '@web5/dids' ;
22import type { EventStream } from '../../src/types/subscriptions.js' ;
3- import type { ResumableTaskManager } from '../../src/core/resumable-task-manager.js' ;
3+ import { ResumableTaskManager } from '../../src/core/resumable-task-manager.js' ;
44import type {
55 DataStore ,
66 EventLog ,
@@ -25,13 +25,12 @@ import { DwnMethodName } from '../../src/enums/dwn-interface-method.js';
2525import { Message } from '../../src/core/message.js' ;
2626import { normalizeSchemaUrl } from '../../src/utils/url.js' ;
2727import { RecordsDeleteHandler } from '../../src/handlers/records-delete.js' ;
28- import { stubInterface } from 'ts-sinon' ;
2928import { TestDataGenerator } from '../utils/test-data-generator.js' ;
3029import { TestEventStream } from '../test-event-stream.js' ;
3130import { TestStores } from '../test-stores.js' ;
3231import { TestStubGenerator } from '../utils/test-stub-generator.js' ;
3332import { Time } from '../../src/utils/time.js' ;
34- import { DataStream , Dwn , Encoder , Jws , RecordsDelete , RecordsRead , RecordsWrite } from '../../src/index.js' ;
33+ import { DataStream , Dwn , Encoder , Jws , MessageStoreLevel , RecordsDelete , RecordsRead , RecordsWrite } from '../../src/index.js' ;
3534import { DidKey , UniversalResolver } from '@web5/dids' ;
3635
3736chai . use ( chaiAsPromised ) ;
@@ -46,6 +45,14 @@ export function testRecordsDeleteHandler(): void {
4645 let eventStream : EventStream ;
4746 let dwn : Dwn ;
4847
48+ beforeEach ( ( ) => {
49+ sinon . restore ( ) ;
50+ } ) ;
51+
52+ after ( ( ) => {
53+ sinon . restore ( ) ;
54+ } ) ;
55+
4956 describe ( 'functional tests' , ( ) => {
5057
5158 // important to follow the `before` and `after` pattern to initialize and clean the stores in tests
@@ -64,8 +71,6 @@ export function testRecordsDeleteHandler(): void {
6471 } ) ;
6572
6673 beforeEach ( async ( ) => {
67- sinon . restore ( ) ; // wipe all previous stubs/spies/mocks/fakes
68-
6974 // clean up before each test rather than after so that a test does not depend on other tests to do the clean up
7075 await messageStore . clear ( ) ;
7176 await dataStore . clear ( ) ;
@@ -764,10 +769,12 @@ export function testRecordsDeleteHandler(): void {
764769 // intentionally not supplying the public key so a different public key is generated to simulate invalid signature
765770 const mismatchingPersona = await TestDataGenerator . generatePersona ( { did : author . did , keyId : author . keyId } ) ;
766771 const didResolver = TestStubGenerator . createDidResolverStub ( mismatchingPersona ) ;
767- const messageStore = stubInterface < MessageStore > ( ) ;
768- const resumableTaskManager = stubInterface < ResumableTaskManager > ( ) ;
769772
770- const recordsDeleteHandler = new RecordsDeleteHandler ( didResolver , messageStore , resumableTaskManager ) ;
773+ // setting up a stub method resolver & message store
774+ const messageStoreStub = sinon . createStubInstance ( MessageStoreLevel ) ;
775+ const resumableTaskManagerStub = sinon . createStubInstance ( ResumableTaskManager ) ;
776+
777+ const recordsDeleteHandler = new RecordsDeleteHandler ( didResolver , messageStoreStub , resumableTaskManagerStub ) ;
771778 const reply = await recordsDeleteHandler . handle ( { tenant, message } ) ;
772779 expect ( reply . status . code ) . to . equal ( 401 ) ;
773780 } ) ;
@@ -777,10 +784,10 @@ export function testRecordsDeleteHandler(): void {
777784 const tenant = author . did ;
778785
779786 // setting up a stub method resolver & message store
780- const messageStore = stubInterface < MessageStore > ( ) ;
781- const resumableTaskManager = stubInterface < ResumableTaskManager > ( ) ;
787+ const messageStoreStub = sinon . createStubInstance ( MessageStoreLevel ) ;
788+ const resumableTaskManagerStub = sinon . createStubInstance ( ResumableTaskManager ) ;
782789
783- const recordsDeleteHandler = new RecordsDeleteHandler ( didResolver , messageStore , resumableTaskManager ) ;
790+ const recordsDeleteHandler = new RecordsDeleteHandler ( didResolver , messageStoreStub , resumableTaskManagerStub ) ;
784791
785792 // stub the `parse()` function to throw an error
786793 sinon . stub ( RecordsDelete , 'parse' ) . throws ( 'anyError' ) ;
0 commit comments