-
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(restaurant): list restaurant use case
- Loading branch information
1 parent
6b407a7
commit 5092437
Showing
3 changed files
with
72 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ListRestaurantUseCase } from "@/restaurant/application/useCases/list-restaurant"; | ||
import { mockRestaurantRepository } from "tests/mocks/restaurant-repository"; | ||
|
||
describe("list restaurant test use case", () => { | ||
let listRestaurant: ListRestaurantUseCase; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
listRestaurant = new ListRestaurantUseCase(mockRestaurantRepository); | ||
}); | ||
|
||
test("when list restaurant then output format", async () => { | ||
const result = await listRestaurant.execute(); | ||
|
||
expect(result).toBeDefined(); | ||
expect(result[0].id).toBeDefined(); | ||
expect(result[0].name).toBeDefined(); | ||
expect(result[0].picture).toBeDefined(); | ||
expect(typeof result[0].address).toBe("string"); | ||
}); | ||
|
||
test("when empty list ten ok", async () => { | ||
mockRestaurantRepository.list.mockResolvedValueOnce([]); | ||
const result = await listRestaurant.execute(); | ||
|
||
expect(result).toBeDefined(); | ||
expect(result.length).toBe(0); | ||
expect(mockRestaurantRepository.list.mock.calls.length).toBe(1); | ||
}); | ||
}); |