import { describe, expect, it } from 'vitest' import { render } from '@solidjs/testing-library' import { createContext, useContext } from 'solid-js' import { createRootRoute, createRouter } from '../src' import { RouterProvider } from '../src/RouterProvider' describe('RouterProvider', () => { it('should provide context through RouterProvider Wrap', async () => { const ctx = createContext() const rootRoute = createRootRoute({ component: () => { const contextValue = useContext(ctx) expect(contextValue, 'Context is not provided').not.toBeUndefined() return
{contextValue}
}, }) const routeTree = rootRoute.addChildren([]) const router = createRouter({ routeTree, }) const app = render(() => ( { return {props.children} }} /> )) const indexElem = await app.findByText('findMe') expect(indexElem).toBeInTheDocument() }) })