-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first try of a test, doesn't work yet
- Loading branch information
1 parent
91db493
commit 8a470b1
Showing
3 changed files
with
39 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
28 changes: 28 additions & 0 deletions
28
src/Resources/tests/unit/api/getParticipationsByDate.spec.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,28 @@ | ||
import useApi from "@/api/api"; | ||
import Participations from "../fixtures/participationsByDate.json"; | ||
import useParticipationsListData from "@/api/getParticipationsByDay"; | ||
import { ref } from "vue"; | ||
|
||
const asyncFunc: () => Promise<void> = async () => { | ||
new Promise(resolve => resolve(undefined)); | ||
}; | ||
|
||
const mockedReturnValue = { | ||
response: ref(Participations), | ||
request: asyncFunc, | ||
error: ref(false) | ||
} | ||
|
||
// @ts-expect-error ts doesn't like mocking with jest.fn() | ||
useApi = jest.fn(useApi); | ||
// @ts-expect-error continuation of expect error from line above | ||
useApi.mockReturnValue(mockedReturnValue); | ||
|
||
describe('Test getParticipations', () => { | ||
it('should return a list of participations', async () => { | ||
const { listData } = useParticipationsListData("16/01/2024"); | ||
|
||
// expect(error.value).toBeFalsy(); | ||
expect(listData).toEqual(Participations); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
src/Resources/tests/unit/fixtures/participationsByDate.json
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,10 @@ | ||
[ | ||
"Alice Meals", | ||
"Bob Meals", | ||
"John Meals", | ||
"Admin Meals", | ||
"Finance Meals", | ||
"Kochomi Meals", | ||
"Jane Meals" | ||
] | ||
|