forked from verdnatura/salix-front
test: refs #8534 add unit tests for stateQueryGuard to ensure proper loading behavior
This commit is contained in:
parent
44e5b136f0
commit
b5e9c381ad
|
@ -15,16 +15,18 @@ vi.mock('src/stores/useStateQueryStore', () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('stateQueryGuard', () => {
|
describe('hooks', () => {
|
||||||
it('espera a que isLoading sea false antes de llamar a next()', async () => {
|
describe('stateQueryGuard', () => {
|
||||||
const next = vi.fn();
|
it('should wait until the state query is not loading and then call next()', async () => {
|
||||||
|
const next = vi.fn();
|
||||||
|
|
||||||
const guardPromise = stateQueryGuard(next);
|
const guardPromise = stateQueryGuard(next);
|
||||||
expect(next).not.toHaveBeenCalled();
|
expect(next).not.toHaveBeenCalled();
|
||||||
|
|
||||||
testStateQuery.isLoading.value = false;
|
testStateQuery.isLoading.value = false;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await guardPromise;
|
await guardPromise;
|
||||||
expect(next).toHaveBeenCalled();
|
expect(next).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue