-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '425-init-sync-process' into 'dev'
fix event synchronization starting point Closes #425 See merge request ergo/rosen-bridge/guard-service!443
- Loading branch information
Showing
4 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Mock } from 'vitest'; | ||
import EventSynchronization from '../../../src/synchronization/EventSynchronization'; | ||
|
||
class EventSynchronizationMock { | ||
private static mockedEventSynchronization: Record<string, any>; | ||
|
||
/** | ||
* resets all mocked functions of EventSynchronization | ||
*/ | ||
static resetMock = () => { | ||
this.mockedEventSynchronization = {}; | ||
}; | ||
|
||
/** | ||
* mocks EventSynchronization.getInstance to return mocked object | ||
*/ | ||
static mock = () => { | ||
const functionSpy = vi.spyOn(EventSynchronization, 'getInstance'); | ||
functionSpy.mockReturnValue( | ||
this.mockedEventSynchronization as EventSynchronization | ||
); | ||
}; | ||
|
||
/** | ||
* mocks EventSynchronization.addEventToQueue | ||
*/ | ||
static mockAddEventToQueue = () => { | ||
this.mockedEventSynchronization.addEventToQueue = vi.fn(); | ||
const functionSpy = vi.spyOn( | ||
this.mockedEventSynchronization, | ||
'addEventToQueue' | ||
); | ||
functionSpy.mockImplementation(() => null); | ||
}; | ||
|
||
/** | ||
* returns vitest mock object of the corresponding function | ||
* @param name function name | ||
* @returns the mock object | ||
*/ | ||
static getMockedFunction = (name: string): Mock<any> => { | ||
return this.mockedEventSynchronization[name]; | ||
}; | ||
} | ||
|
||
export default EventSynchronizationMock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters