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({
|
const [state, setState] = useState({
|
||||||
session: null,
|
session: null,
|
||||||
status: 'disconnected',
|
status: 'disconnected',
|
||||||
first: true,
|
|
||||||
loggingOut: false,
|
loggingOut: false,
|
||||||
adminToken: null,
|
adminToken: null,
|
||||||
version: getVersion(),
|
version: getVersion(),
|
||||||
@ -53,7 +52,7 @@ export function useAppContext() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setSession = async () => {
|
const setSession = async () => {
|
||||||
updateState({ session: true });
|
updateState({ session: true, status: 'connecting' });
|
||||||
await account.actions.setSession(access.current);
|
await account.actions.setSession(access.current);
|
||||||
await profile.actions.setSession(access.current);
|
await profile.actions.setSession(access.current);
|
||||||
await card.actions.setSession(access.current);
|
await card.actions.setSession(access.current);
|
||||||
@ -153,7 +152,7 @@ export function useAppContext() {
|
|||||||
try {
|
try {
|
||||||
delay.current = 0;
|
delay.current = 0;
|
||||||
const rev = JSON.parse(ev.data);
|
const rev = JSON.parse(ev.data);
|
||||||
updateState({ first: false, status: 'connected' });
|
updateState({ status: 'connected' });
|
||||||
profile.actions.setRevision(rev.profile);
|
profile.actions.setRevision(rev.profile);
|
||||||
account.actions.setRevision(rev.account);
|
account.actions.setRevision(rev.account);
|
||||||
channel.actions.setRevision(rev.channel);
|
channel.actions.setRevision(rev.channel);
|
||||||
|
@ -78,6 +78,11 @@ beforeEach(() => {
|
|||||||
React.useContext = mockUseContext;
|
React.useContext = mockUseContext;
|
||||||
|
|
||||||
const mockFetch = jest.fn().mockImplementation((url, options) => {
|
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({
|
return Promise.resolve({
|
||||||
json: () => Promise.resolve([])
|
json: () => Promise.resolve([])
|
||||||
});
|
});
|
||||||
@ -103,7 +108,7 @@ test('testing', async () => {
|
|||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
const app = screen.getByTestId('app').props.app;
|
const app = screen.getByTestId('app').props.app;
|
||||||
app.actions.login('testlogin', 'testpassword');
|
app.actions.login('testlogin@test.org', 'testpassword');
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitFor(async () => {
|
await waitFor(async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user