Skip to content

Commit

Permalink
direct call to getListData
Browse files Browse the repository at this point in the history
  • Loading branch information
AYAxDesign committed Feb 5, 2024
1 parent feb60d9 commit ddd063f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/Resources/src/api/getParticipationsByDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const listDataState = ref([])
* @param date
* @returns list of participants
*/
export async function useParticipationsListData(date: string, isTesting = false){
export async function useParticipationsListData(date: string){

const loaded = ref(false)
let useParticipationsError = false
Expand Down Expand Up @@ -41,11 +41,8 @@ export async function useParticipationsListData(date: string, isTesting = false)
listDataState.value = listData.value;
}
}
if (isTesting) {
getListData();
}
return {
useParticipationsError, listData: readonly(listDataState)
useParticipationsError, listData: readonly(listDataState), getListData
};
}

8 changes: 4 additions & 4 deletions src/Resources/tests/unit/api/getParticipationsByDate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import useApi from "@/api/api";
import Participations from "../fixtures/participationsByDate.json";
import {useParticipationsListData} from "@/api/getParticipationsByDay";
import { useParticipationsListData } from "@/api/getParticipationsByDay";
import { ref } from "vue";
import Participations from "../fixtures/participationsByDate.json";

const asyncFunc: () => Promise<void> = async () => {
new Promise(resolve => resolve(undefined));
Expand All @@ -20,8 +20,8 @@ useApi.mockReturnValue(mockedReturnValue);

describe('Test getParticipations', () => {
it('should return a list of participations', async () => {
const {useParticipationsError, listData} = await useParticipationsListData("2024-01-16",true);

const {useParticipationsError, listData, getListData} = await useParticipationsListData("2024-01-16");
await getListData();
expect(useParticipationsError).toBeFalsy();
expect(listData.value).toEqual(Participations);
});
Expand Down

0 comments on commit ddd063f

Please sign in to comment.