From a6b13a77c8d4eccdfb41009f0e47cf7ce381e96a Mon Sep 17 00:00:00 2001 From: balzack Date: Sat, 31 Dec 2022 11:40:25 -0800 Subject: [PATCH] making profile test more functional --- net/web/test/Profile.test.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/web/test/Profile.test.js b/net/web/test/Profile.test.js index 477a646f..f10b6681 100644 --- a/net/web/test/Profile.test.js +++ b/net/web/test/Profile.test.js @@ -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 ( -
+
{ profile.state.profile?.guid } { profile.state.profile?.handle } { profile.state.profile?.name } @@ -55,10 +57,24 @@ afterEach(() => { test('testing', async () => { render(); + 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"); + }); + });