mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
more app context cleanup
This commit is contained in:
parent
c511f844ba
commit
6c2d1b225d
@ -17,7 +17,6 @@ export function useAppContext() {
|
||||
const [state, setState] = useState({
|
||||
session: null,
|
||||
status: 'disconnected',
|
||||
first: true,
|
||||
loggingOut: false,
|
||||
adminToken: null,
|
||||
version: getVersion(),
|
||||
@ -53,7 +52,7 @@ export function useAppContext() {
|
||||
}, []);
|
||||
|
||||
const setSession = async () => {
|
||||
updateState({ session: true });
|
||||
updateState({ session: true, status: 'connecting' });
|
||||
await account.actions.setSession(access.current);
|
||||
await profile.actions.setSession(access.current);
|
||||
await card.actions.setSession(access.current);
|
||||
@ -153,7 +152,7 @@ export function useAppContext() {
|
||||
try {
|
||||
delay.current = 0;
|
||||
const rev = JSON.parse(ev.data);
|
||||
updateState({ first: false, status: 'connected' });
|
||||
updateState({ status: 'connected' });
|
||||
profile.actions.setRevision(rev.profile);
|
||||
account.actions.setRevision(rev.account);
|
||||
channel.actions.setRevision(rev.channel);
|
||||
|
@ -78,6 +78,11 @@ beforeEach(() => {
|
||||
React.useContext = mockUseContext;
|
||||
|
||||
const mockFetch = jest.fn().mockImplementation((url, options) => {
|
||||
if (url.startsWith('https://test.org/account/apps')) {
|
||||
return Promise.resolve({
|
||||
json: () => Promise.resolve({ guid: '123', appToken: 'abc' })
|
||||
});
|
||||
}
|
||||
return Promise.resolve({
|
||||
json: () => Promise.resolve([])
|
||||
});
|
||||
@ -103,7 +108,7 @@ test('testing', async () => {
|
||||
|
||||
await act(async () => {
|
||||
const app = screen.getByTestId('app').props.app;
|
||||
app.actions.login('testlogin', 'testpassword');
|
||||
app.actions.login('testlogin@test.org', 'testpassword');
|
||||
});
|
||||
|
||||
await waitFor(async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user