mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
making profile test more functional
This commit is contained in:
parent
a0ccc11775
commit
a6b13a77c8
@ -3,11 +3,13 @@ import {render, act, screen, waitFor, fireEvent} from '@testing-library/react'
|
||||
import { ProfileContextProvider, ProfileContext } from 'context/ProfileContext';
|
||||
import * as fetchUtil from 'api/fetchUtil';
|
||||
|
||||
let profileContext = null;
|
||||
function ProfileView() {
|
||||
const profile = useContext(ProfileContext);
|
||||
profileContext = profile;
|
||||
|
||||
return (
|
||||
<div data-testid="profile" profile={profile}>
|
||||
<div>
|
||||
<span data-testid="guid">{ profile.state.profile?.guid }</span>
|
||||
<span data-testid="handle">{ profile.state.profile?.handle }</span>
|
||||
<span data-testid="name">{ profile.state.profile?.name }</span>
|
||||
@ -55,10 +57,24 @@ afterEach(() => {
|
||||
test('testing', async () => {
|
||||
render(<ProfileTestApp />);
|
||||
|
||||
await waitFor(async () => {
|
||||
expect(profileContext).not.toBe(null);
|
||||
});
|
||||
|
||||
await waitFor(async () => {
|
||||
expect(screen.getByTestId('name').textContent).toBe("");
|
||||
});
|
||||
|
||||
|
||||
await act(async () => {
|
||||
identity = { name: 'jester' };
|
||||
await profileContext.actions.setToken({ guid: 'abc', server: 'test.org', appToken: '123' });
|
||||
await profileContext.actions.setRevision(1);
|
||||
});
|
||||
|
||||
await waitFor(async () => {
|
||||
expect(screen.getByTestId('name').textContent).toBe("jester");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user