-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aaron Chong <[email protected]>
- Loading branch information
1 parent
a27ce65
commit 2d54d4d
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/rmf-dashboard-framework/src/components/admin/user-profile-page.test.tsx
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,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(); | ||
}); | ||
}); |