diff --git a/package.json b/package.json index 6b84439c7..1bc3676eb 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "license": "Apache-2.0", "scripts": { + "clean": "rimraf -g **/.turbo **/.next **/coverage", "build": "turbo run build", "build:libs": "turbo run build --filter=./packages/**", "dev": "turbo run dev", diff --git a/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts b/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts index 728541b39..404e4093a 100644 --- a/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts +++ b/packages/device-management-kit/src/internal/device-session/service/DefaultDeviceSessionService.test.ts @@ -38,47 +38,44 @@ describe("DefaultDeviceSessionService", () => { ); }); + afterEach(() => { + deviceSession.close(); + }); + it("should have an empty sessions list", () => { expect(sessionService.getDeviceSessions()).toEqual([]); - deviceSession.close(); }); it("should add a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); it("should not add a deviceSession if it already exists", () => { sessionService.addDeviceSession(deviceSession); sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); it("should remove a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); sessionService.removeDeviceSession(deviceSession.id); expect(sessionService.getDeviceSessions()).toEqual([]); }); it("should not remove a deviceSession if it does not exist", () => { - deviceSession.close(); sessionService.removeDeviceSession(deviceSession.id); expect(sessionService.getDeviceSessions()).toEqual([]); }); it("should get a deviceSession", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual( Either.of(deviceSession), ); }); it("should not get a deviceSession if it does not exist", () => { - deviceSession.close(); expect(sessionService.getDeviceSessionById(deviceSession.id)).toEqual( Left(new DeviceSessionNotFound()), ); @@ -86,7 +83,6 @@ describe("DefaultDeviceSessionService", () => { it("should get all sessions", () => { sessionService.addDeviceSession(deviceSession); - deviceSession.close(); expect(sessionService.getDeviceSessions()).toEqual([deviceSession]); }); @@ -94,7 +90,6 @@ describe("DefaultDeviceSessionService", () => { expect(sessionService.sessionsObs).toBeInstanceOf( Observable, ); - deviceSession.close(); }); it("should emit new session", (done) => { @@ -106,7 +101,6 @@ describe("DefaultDeviceSessionService", () => { }, }); sessionService.addDeviceSession(deviceSession); - deviceSession.close(); }); it("should emit previous added session", () => { @@ -124,7 +118,6 @@ describe("DefaultDeviceSessionService", () => { emittedSessions.push(emittedDeviceSession); }, }); - deviceSession.close(); lastDeviceSession.close(); expect(emittedSessions).toEqual([deviceSession, lastDeviceSession]); subscription.unsubscribe(); diff --git a/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts b/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts index cdeb03f85..87c60167d 100644 --- a/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts +++ b/packages/device-management-kit/src/internal/discovery/use-case/ConnectUseCase.test.ts @@ -57,6 +57,12 @@ describe("ConnectUseCase", () => { managerApi = new DefaultManagerApiService(managerApiDataSource); }); + afterEach(() => { + for (const session of sessionService.getDeviceSessions()) { + sessionService.removeDeviceSession(session.id); + } + }); + afterAll(() => { jest.restoreAllMocks(); }); @@ -94,5 +100,6 @@ describe("ConnectUseCase", () => { device: stubDiscoveredDevice, }); expect(sessionId).toBe(fakeSessionId); + sessionService.removeDeviceSession(sessionId); }); }); diff --git a/turbo.json b/turbo.json index 22ffdaaf4..9e61593ab 100644 --- a/turbo.json +++ b/turbo.json @@ -1,5 +1,6 @@ { "$schema": "https://turborepo.org/schema.json", + "globalDependencies": ["turbo.json"], "ui": "tui", "tasks": { "build": { @@ -41,6 +42,14 @@ "dependsOn": ["^build", "^typecheck"], "outputs": [] }, + "@ledgerhq/device-management-kit-sample#typecheck": { + "dependsOn": ["build", "^typecheck"], + "outputs": [] + }, + "@ledgerhq/ledger-dmk-docs#typecheck": { + "dependsOn": ["build", "^typecheck"], + "outputs": [] + }, "health-check": { "dependsOn": ["build", "prettier", "lint", "typecheck"] }