-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test cov for list, remove and create specs
- Loading branch information
Showing
8 changed files
with
274 additions
and
33 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
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
50 changes: 50 additions & 0 deletions
50
src/features/project-workspace/opfs-project-service.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,50 @@ | ||
import { retrieveProject } from "./opfs-project-service"; | ||
import * as opfsAdapters from "../../services/origin-private-file-system"; | ||
|
||
jest.mock("../../services/origin-private-file-system"); | ||
|
||
describe("OPFS project service", () => { | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
test("project retrieval is integrated with the most primitive OPFS service module", async () => { | ||
(opfsAdapters.makeOpfsMainDirAdapter as jest.Mock).mockResolvedValueOnce({ | ||
retrieveFilenames: jest | ||
.fn() | ||
.mockResolvedValue([ | ||
"82184240-6b29-4ae8-82f5-fbe7d1bb814a_MyAPI.json", | ||
"e5ae94f4-2c32-4129-a2b1-cdf2c4c770dc_Biohazard API.json", | ||
]), | ||
}); | ||
|
||
(opfsAdapters.makeOpfsFileAdapter as jest.Mock).mockImplementationOnce( | ||
(options: { filename: string }) => { | ||
if ( | ||
!options.filename.startsWith("e5ae94f4-2c32-4129-a2b1-cdf2c4c770dc") | ||
) { | ||
throw new Error("Unexpected test case."); | ||
} | ||
|
||
return { | ||
retrieve: jest.fn().mockImplementation(async () => { | ||
return { | ||
uuid: "e5ae94f4-2c32-4129-a2b1-cdf2c4c770dc", | ||
name: "Biohazard API", | ||
mocked: "content", | ||
}; | ||
}), | ||
}; | ||
} | ||
); | ||
|
||
const content = await retrieveProject( | ||
"e5ae94f4-2c32-4129-a2b1-cdf2c4c770dc" | ||
); | ||
expect(content).toEqual({ | ||
uuid: "e5ae94f4-2c32-4129-a2b1-cdf2c4c770dc", | ||
name: "Biohazard API", | ||
mocked: "content", | ||
}); | ||
}); | ||
}); |
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
6 changes: 3 additions & 3 deletions
6
src/features/projects-management/opfs-projects-listing-service.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
Oops, something went wrong.