-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ce4749
commit ccbda27
Showing
5 changed files
with
109 additions
and
13 deletions.
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
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
51 changes: 51 additions & 0 deletions
51
packages/core/src/internal/device-session/use-case/CloseSessionsUseState.test.ts
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,51 @@ | ||
import { deviceSessionStubBuilder } from "@internal/device-session/model/DeviceSession.stub"; | ||
import { DefaultDeviceSessionService } from "@internal/device-session/service/DefaultDeviceSessionService"; | ||
import { DeviceSessionService } from "@internal/device-session/service/DeviceSessionService"; | ||
import { CloseSessionsUseCase } from "@internal/device-session/use-case/CloseSessionsUseCase"; | ||
import { DefaultLoggerPublisherService } from "@internal/logger-publisher/service/DefaultLoggerPublisherService"; | ||
import { LoggerPublisherService } from "@internal/logger-publisher/service/LoggerPublisherService"; | ||
import { AxiosManagerApiDataSource } from "@internal/manager-api/data/AxiosManagerApiDataSource"; | ||
import { ManagerApiDataSource } from "@internal/manager-api/data/ManagerApiDataSource"; | ||
import { DefaultManagerApiService } from "@internal/manager-api/service/DefaultManagerApiService"; | ||
import { ManagerApiService } from "@internal/manager-api/service/ManagerApiService"; | ||
|
||
let logger: LoggerPublisherService; | ||
let managerApiDataSource: ManagerApiDataSource; | ||
let managerApi: ManagerApiService; | ||
let sessionService: DeviceSessionService; | ||
|
||
describe("CloseSessionsUseState", () => { | ||
beforeEach(() => { | ||
logger = new DefaultLoggerPublisherService( | ||
[], | ||
"close-sessions-use-case-test", | ||
); | ||
managerApiDataSource = new AxiosManagerApiDataSource({ | ||
managerApiUrl: "http://fake.url", | ||
mockUrl: "http://fake-mock.url", | ||
}); | ||
managerApi = new DefaultManagerApiService(managerApiDataSource); | ||
sessionService = new DefaultDeviceSessionService(() => logger); | ||
}); | ||
|
||
it("should be able to close every session", () => { | ||
//given | ||
const sessions = [...Array(10).keys()].map((id) => { | ||
const session = deviceSessionStubBuilder( | ||
{ id: id.toString() }, | ||
() => logger, | ||
managerApi, | ||
); | ||
jest.spyOn(session, "close"); | ||
return session; | ||
}); | ||
sessions.forEach((session) => sessionService.addDeviceSession(session)); | ||
const useCase = new CloseSessionsUseCase(sessionService); | ||
//when | ||
useCase.execute(); | ||
//then | ||
sessions.forEach((session) => { | ||
expect(session.close).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
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