Skip to content

Commit

Permalink
Fix Failing Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Peyton-McKee committed Jan 22, 2025
1 parent 9074519 commit 6783610
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const EditAvailability: React.FC<EditAvailabilityProps> = ({

useEffect(() => {
if (editedAvailabilities) {

}
}, [editedAvailabilities, initialDate]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { exampleAdminUser } from '../../test-support/test-data/users.stub';
import AppContextUser from '../../../app/AppContextUser';
import { useAllUsers, useLogUserIn } from '../../../hooks/users.hooks';
import * as userHooks from '../../../hooks/users.hooks';
import { mockLogUserInReturnValue, mockLogUserInDevReturnValue } from '../../test-support/mock-hooks';
import {
mockLogUserInReturnValue,
mockLogUserInDevReturnValue,
mockGetCurrentUserValue
} from '../../test-support/mock-hooks';

vi.mock('../../../hooks/projects.hooks');
vi.mock('../../../hooks/users.hooks');
Expand Down Expand Up @@ -64,6 +68,7 @@ describe('Implement change request permission tests', () => {
vi.spyOn(userHooks, 'useLogUserInDev').mockReturnValue(mockLogUserInDevReturnValue);
vi.spyOn(userHooks, 'useCurrentUser').mockReturnValue(exampleAdminUser);
vi.spyOn(authHooks, 'useAuth').mockReturnValue(mockAuth(false, exampleAdminUser));
vi.spyOn(userHooks, 'useGetCurrentUser').mockReturnValue(mockGetCurrentUserValue);
});

const actionBtnText = 'Implement Change Request';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { mockUseMutationResult, mockUseQueryResult } from '../../../test-support
import { exampleUserSettingsLight } from '../../../test-support/test-data/user-settings.stub';
import { fireEvent, render, screen } from '../../../test-support/test-utils';
import UserSettingsComponent from '../../../../pages/SettingsPage/UserSettings/UserSettings';
import { mockLogUserInReturnValue, mockLogUserInDevReturnValue } from '../../../test-support/mock-hooks';
import {
mockLogUserInReturnValue,
mockLogUserInDevReturnValue,
mockGetCurrentUserValue
} from '../../../test-support/mock-hooks';

vi.mock('../../../../pages/SettingsPage/UserSettings/UserSettingsView', () => {
return {
Expand Down Expand Up @@ -76,6 +80,7 @@ describe('user settings component', () => {
beforeEach(() => {
vi.spyOn(userHooks, 'useLogUserIn').mockReturnValue(mockLogUserInReturnValue);
vi.spyOn(userHooks, 'useLogUserInDev').mockReturnValue(mockLogUserInDevReturnValue);
vi.spyOn(userHooks, 'useGetCurrentUser').mockReturnValue(mockGetCurrentUserValue);
});

it('renders everything', () => {
Expand Down
11 changes: 9 additions & 2 deletions src/frontend/src/tests/test-support/mock-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,24 @@ import { exampleAdminUser } from './test-data/users.stub';
export const mockLogUserInReturnValue = mockUseMutationResult<AuthenticatedUser>(
false,
false,
exampleAdminUser as AuthenticatedUser,
exampleAdminUser,
new Error()
) as UseMutationResult<AuthenticatedUser, Error, string, unknown>;

export const mockLogUserInDevReturnValue = mockUseMutationResult<AuthenticatedUser>(
false,
false,
exampleAdminUser as AuthenticatedUser,
exampleAdminUser,
new Error()
) as UseMutationResult<AuthenticatedUser, Error, string, unknown>;

export const mockGetCurrentUserValue = mockUseMutationResult<AuthenticatedUser>(
false,
false,
exampleAdminUser,
new Error()
) as UseMutationResult<AuthenticatedUser, Error, void, unknown>;

export const mockUseAllUsersReturnValue = (users: User[]) => mockUseQueryResult<User[]>(false, false, users, new Error());

export const mockUseSingleUserSettings = (settings?: UserSettings) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export const mockAuth = (isLoading: boolean, user?: User) => {
devSignin: () => new Promise((res) => res(exampleAuthenticatedAdminUser)),
signin: () => new Promise((res) => res(exampleAuthenticatedAdminUser)),
signout: () => {},
isLoading
isLoading,
signInCurrent: () => new Promise((res) => res()),
triedCurrent: true
} as Auth;
};

Expand Down

0 comments on commit 6783610

Please sign in to comment.