Skip to content

Commit

Permalink
user-profile-page
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <[email protected]>
  • Loading branch information
aaronchongth committed Nov 25, 2024
1 parent a27ce65 commit 2d54d4d
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { render as render_, waitFor } from '@testing-library/react';
import React from 'react';
import { describe, expect, it } from 'vitest';

import { AppControllerProvider, RmfApiProvider } from '../../hooks';
import { RmfApi } from '../../services';
import { makeMockAppController, MockRmfApi, TestProviders } from '../../utils/test-utils.test';
import { UserProfilePage } from './user-profile-page';

const render = (ui: React.ReactNode) =>
render_(<AppControllerProvider value={makeMockAppController()}>{ui}</AppControllerProvider>);

describe('UserProfilePage', () => {
const Base = (props: React.PropsWithChildren<{}>) => {
const rmfApi = React.useMemo<RmfApi>(() => {
const mockRmfApi = new MockRmfApi();
// mock out some api calls so they never resolves
mockRmfApi.adminApi.getUserAdminUsersUsernameGet = () => new Promise(() => {});
mockRmfApi.adminApi.makeAdminAdminUsersUsernameMakeAdminPost = () => new Promise(() => {});
mockRmfApi.adminApi.getRolesAdminRolesGet = () => new Promise(() => {});
mockRmfApi.adminApi.setUserRolesAdminUsersUsernameRolesPut = () => new Promise(() => {});
return mockRmfApi;
}, []);
return (
<TestProviders>
<RmfApiProvider value={rmfApi}>{props.children}</RmfApiProvider>
</TestProviders>
);
};

it('renders user profile page', async () => {
await expect(
waitFor(() =>
render(
<Base>
<UserProfilePage />
</Base>,
),
),
).resolves.not.toThrow();
});
});

0 comments on commit 2d54d4d

Please sign in to comment.