Skip to content

Commit b5d6f5c

Browse files
committed
#2063 tests
1 parent becdb28 commit b5d6f5c

3 files changed

Lines changed: 80 additions & 1 deletion

File tree

src/frontend/src/hooks/design-reviews.hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { DesignReview } from 'shared';
1111
*
1212
* @returns all the design reviews
1313
*/
14-
export const useGetAllDesignReviews = () => {
14+
export const useAllDesignReviews = () => {
1515
return useQuery<DesignReview[], Error>(['design-reviews'], async () => {
1616
const { data } = await getAllDesignReviews();
1717
return data;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
6+
import { renderHook } from '@testing-library/react-hooks';
7+
import { AxiosResponse } from 'axios';
8+
import { DesignReview } from 'shared';
9+
import wrapper from '../../app/AppContextQuery';
10+
import { mockPromiseAxiosResponse } from '../test-support/test-data/test-utils.stub';
11+
import { exampleAllDesignReviews } from '../test-support/test-data/design-reviews.stub';
12+
import { getAllDesignReviews } from '../../apis/design-reviews.api';
13+
import { useAllDesignReviews } from '../../hooks/design-reviews.hooks';
14+
15+
vi.mock('../../apis/design-reviews.api');
16+
17+
describe('design review hooks', () => {
18+
it('handles getting a list of design reviews', async () => {
19+
const mockedGetAllDesignReviews = getAllDesignReviews as jest.Mock<Promise<AxiosResponse<DesignReview[]>>>;
20+
mockedGetAllDesignReviews.mockReturnValue(mockPromiseAxiosResponse<DesignReview[]>(exampleAllDesignReviews));
21+
22+
const { result, waitFor } = renderHook(() => useAllDesignReviews(), { wrapper });
23+
await waitFor(() => result.current.isSuccess);
24+
expect(result.current.data).toEqual(exampleAllDesignReviews);
25+
});
26+
});
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
6+
import { DesignReview, DesignReviewStatus, TeamType } from 'shared';
7+
import { exampleAdminUser, exampleAppAdminUser } from './users.stub';
8+
import { exampleWbsProject1 } from './wbs-numbers.stub';
9+
10+
export const teamType1: TeamType = {
11+
teamTypeId: '1',
12+
name: 'teamType1'
13+
};
14+
15+
export const exampleDesignReview1: DesignReview = {
16+
designReviewId: '1',
17+
dateScheduled: new Date('2024-03-25'),
18+
meetingTimes: [0, 1, 2, 3],
19+
dateCreated: new Date('2024-03-10'),
20+
userCreated: exampleAdminUser,
21+
status: DesignReviewStatus.CONFIRMED,
22+
teamType: teamType1,
23+
requiredMembers: [exampleAdminUser],
24+
optionalMembers: [],
25+
confirmedMembers: [exampleAdminUser],
26+
deniedMembers: [],
27+
isOnline: true,
28+
isInPerson: false,
29+
attendees: [exampleAdminUser],
30+
wbsName: '1',
31+
wbsNum: exampleWbsProject1
32+
};
33+
34+
export const exampleDesignReview2: DesignReview = {
35+
designReviewId: '2',
36+
dateScheduled: new Date('2024-03-25'),
37+
meetingTimes: [0, 4],
38+
dateCreated: new Date('2024-03-10'),
39+
userCreated: exampleAppAdminUser,
40+
status: DesignReviewStatus.CONFIRMED,
41+
teamType: teamType1,
42+
requiredMembers: [exampleAppAdminUser],
43+
optionalMembers: [],
44+
confirmedMembers: [exampleAppAdminUser],
45+
deniedMembers: [],
46+
isOnline: false,
47+
isInPerson: true,
48+
attendees: [exampleAppAdminUser],
49+
wbsName: '1',
50+
wbsNum: exampleWbsProject1
51+
};
52+
53+
export const exampleAllDesignReviews: DesignReview[] = [exampleDesignReview1, exampleDesignReview2];

0 commit comments

Comments
 (0)