Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nemanjamalesija committed Jan 14, 2025
1 parent 680a2c6 commit 4fac43a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/data-loaders/navigation-guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,33 @@ describe('navigation-guard', () => {
'does not call commit for a loader if the navigation is canceled by another loader'
)

it.todo('sets isDataLoading within a navigation', () => {
it('sets isDataLoading within a navigation', async () => {
const { app } = setupApp({ isSSR: false })
const isGloballyLoading = app.runWithContext(() => useIsDataLoading())
expect(isGloballyLoading.value).toBe(false)

const router = getRouter()
const l1 = mockedLoader()
const l2 = mockedLoader()
router.addRoute({
name: '_test',
path: '/fetch',
component,
meta: {
loaders: [l1.loader, l2.loader],
},
})

router.push('/fetch')
await vi.runOnlyPendingTimersAsync()
expect(isGloballyLoading.value).toBe(true)

l1.resolve()
await vi.runAllTimersAsync();
expect(isGloballyLoading.value).toBe(true)
l2.resolve()
await vi.runAllTimersAsync()
expect(isGloballyLoading.value).toBe(false)
})

describe('signal', () => {
Expand Down

0 comments on commit 4fac43a

Please sign in to comment.