async def test_router_var_dep(state_manager: StateManager, token: str) -> None:
    """Test that router var dependencies are correctly tracked.

    Args:
        state_manager: A state manager.
        token: A token.
    """

    class RouterVarParentState(State):
        """A parent state for testing router var dependency."""

    class RouterVarDepState(RouterVarParentState):
        """A state with a router var dependency."""

        @rx.var
        def foo(self) -> str:
            return self.router.page.params.get("foo", "")

    foo = RouterVarDepState.computed_vars["foo"]
    State._init_var_dependency_dicts()

    assert foo._deps(objclass=RouterVarDepState) == {
        RouterVarDepState.get_full_name(): {"router"}
    }
    assert (RouterVarDepState.get_full_name(), "foo") in State._var_dependencies[
        "router"
    ]

    # Get state from state manager.
    state_manager.state = State
    rx_state = await state_manager.get_state(_substate_key(token, State))
    assert RouterVarParentState.get_name() in rx_state.substates
    parent_state = rx_state.substates[RouterVarParentState.get_name()]
    assert RouterVarDepState.get_name() in parent_state.substates
    state = parent_state.substates[RouterVarDepState.get_name()]

    assert state.dirty_vars == set()

    # Reassign router var
    state.router = state.router
    assert rx_state.dirty_vars == {"router"}
    assert state.dirty_vars == {"foo"}
    assert parent_state.dirty_substates == {RouterVarDepState.get_name()}
Test that router var dependencies are correctly tracked.

    Args:
        state_manager: A state manager.
        token: A token.
    
tests/units/test_state.py