From b5e9c381ad078910156e1d53a190b058bac1a64f Mon Sep 17 00:00:00 2001 From: alexm Date: Sun, 23 Mar 2025 11:59:53 +0100 Subject: [PATCH] test: refs #8534 add unit tests for stateQueryGuard to ensure proper loading behavior --- .../{index.spec.js => hooks.spec.js} | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) rename src/router/__tests__/{index.spec.js => hooks.spec.js} (50%) diff --git a/src/router/__tests__/index.spec.js b/src/router/__tests__/hooks.spec.js similarity index 50% rename from src/router/__tests__/index.spec.js rename to src/router/__tests__/hooks.spec.js index d0a2a9b0dd..7fa4161631 100644 --- a/src/router/__tests__/index.spec.js +++ b/src/router/__tests__/hooks.spec.js @@ -15,16 +15,18 @@ vi.mock('src/stores/useStateQueryStore', () => { }; }); -describe('stateQueryGuard', () => { - it('espera a que isLoading sea false antes de llamar a next()', async () => { - const next = vi.fn(); +describe('hooks', () => { + describe('stateQueryGuard', () => { + it('should wait until the state query is not loading and then call next()', async () => { + const next = vi.fn(); - const guardPromise = stateQueryGuard(next); - expect(next).not.toHaveBeenCalled(); + const guardPromise = stateQueryGuard(next); + expect(next).not.toHaveBeenCalled(); - testStateQuery.isLoading.value = false; - await nextTick(); - await guardPromise; - expect(next).toHaveBeenCalled(); + testStateQuery.isLoading.value = false; + await nextTick(); + await guardPromise; + expect(next).toHaveBeenCalled(); + }); }); });