@veloxts/client 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,264 +1,50 @@
1
1
  # @veloxts/client
2
2
 
3
- > **Alpha Release** - This framework is in early development. APIs may change between versions. Not recommended for production use yet.
3
+ **Pre-Alpha Notice:** This framework is in early development (v0.4.x). APIs are subject to change. Not recommended for production use.
4
4
 
5
- Type-safe frontend API client for the VeloxTS framework.
5
+ ## What is this?
6
6
 
7
- ## Features
7
+ Type-safe frontend API client for the VeloxTS Framework, with zero code generation and full type inference from backend procedures.
8
8
 
9
- - **Zero code generation** - Types inferred directly from backend procedure definitions
10
- - **Full type safety** - Autocomplete and compile-time type checking
11
- - **Fetch-based** - Works in both browser and Node.js environments
12
- - **Error handling** - Typed error classes with full response context
13
- - **Interceptors** - Request, response, and error hooks
14
- - **REST integration** - Maps to auto-generated REST endpoints
9
+ ## Part of @veloxts/velox
15
10
 
16
- ## Installation
11
+ This package is part of the VeloxTS Framework. For the complete framework experience, install:
17
12
 
18
13
  ```bash
19
- npm install @veloxts/client
20
- ```
21
-
22
- ## Usage
23
-
24
- ### Basic Setup
25
-
26
- ```typescript
27
- // Import your backend procedure types
28
- import type { userProcedures, postProcedures } from '../server/procedures';
29
- import { createClient } from '@veloxts/client';
30
-
31
- // Create a typed client
32
- const api = createClient<{
33
- users: typeof userProcedures;
34
- posts: typeof postProcedures;
35
- }>({
36
- baseUrl: '/api',
37
- });
38
-
39
- // Make fully typed API calls
40
- const user = await api.users.getUser({ id: '123' });
41
- // user is typed as User (inferred from backend output schema)
42
-
43
- const users = await api.users.listUsers({ page: 1, limit: 10 });
44
- // users is typed as User[] (or whatever your output schema defines)
45
-
46
- const newUser = await api.users.createUser({
47
- name: 'Alice',
48
- email: 'alice@example.com'
49
- });
50
- // newUser is typed as User
14
+ npm install @veloxts/velox
51
15
  ```
52
16
 
53
- ### Custom Configuration
54
-
55
- ```typescript
56
- const api = createClient<Router>({
57
- baseUrl: 'https://api.example.com/api',
58
-
59
- // Add custom headers to all requests
60
- headers: {
61
- 'Authorization': 'Bearer token123',
62
- },
17
+ Visit [@veloxts/velox](https://www.npmjs.com/package/@veloxts/velox) for the complete framework documentation.
63
18
 
64
- // Request interceptor
65
- onRequest: async (url, options) => {
66
- console.log(`${options.method} ${url}`);
67
- },
19
+ ## Standalone Installation
68
20
 
69
- // Response interceptor
70
- onResponse: async (response) => {
71
- console.log(`Response: ${response.status}`);
72
- },
73
-
74
- // Error interceptor
75
- onError: async (error) => {
76
- console.error('API Error:', error.message);
77
- // You can track errors, show notifications, etc.
78
- },
79
- });
21
+ ```bash
22
+ npm install @veloxts/client
80
23
  ```
81
24
 
82
- ### Error Handling
83
-
84
- The client provides typed error classes for different error scenarios:
85
-
86
- ```typescript
87
- import {
88
- isVeloxClientError,
89
- isClientValidationError,
90
- isClientNotFoundError,
91
- isServerError,
92
- isNetworkError,
93
- } from '@veloxts/client';
25
+ ## Documentation
94
26
 
95
- try {
96
- const user = await api.users.getUser({ id: 'invalid' });
97
- } catch (error) {
98
- if (isClientValidationError(error)) {
99
- // Handle validation errors (400)
100
- console.log('Validation failed:', error.fields);
101
- } else if (isClientNotFoundError(error)) {
102
- // Handle not found errors (404)
103
- console.log('Resource not found:', error.resource);
104
- } else if (isServerError(error)) {
105
- // Handle server errors (5xx)
106
- console.log('Server error:', error.statusCode);
107
- } else if (isNetworkError(error)) {
108
- // Handle network errors (can't reach server)
109
- console.log('Network error:', error.message);
110
- } else if (isVeloxClientError(error)) {
111
- // Generic client error
112
- console.log('Error:', error.statusCode, error.message);
113
- }
114
- }
115
- ```
27
+ For detailed documentation, usage examples, and API reference, see [GUIDE.md](./GUIDE.md).
116
28
 
117
- ### Using with React
29
+ ## Quick Example
118
30
 
119
31
  ```typescript
120
- // hooks/useApi.ts
121
32
  import { createClient } from '@veloxts/client';
122
- import type { AppRouter } from '../server/procedures';
123
-
124
- export const api = createClient<AppRouter>({
125
- baseUrl: import.meta.env.VITE_API_URL || '/api',
126
- });
127
-
128
- // In your component
129
- import { api } from './hooks/useApi';
130
- import { useState, useEffect } from 'react';
131
-
132
- function UserProfile({ userId }: { userId: string }) {
133
- const [user, setUser] = useState(null);
134
- const [loading, setLoading] = useState(true);
135
- const [error, setError] = useState(null);
136
-
137
- useEffect(() => {
138
- api.users.getUser({ id: userId })
139
- .then(setUser)
140
- .catch(setError)
141
- .finally(() => setLoading(false));
142
- }, [userId]);
143
-
144
- if (loading) return <div>Loading...</div>;
145
- if (error) return <div>Error: {error.message}</div>;
33
+ import type { userProcedures } from '../server/procedures';
146
34
 
147
- return <div>User: {user.name}</div>;
148
- }
149
- ```
150
-
151
- ### Using with React Query (Recommended)
152
-
153
- ```typescript
154
- import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
155
- import { api } from './hooks/useApi';
156
-
157
- // Query hook
158
- function useUser(userId: string) {
159
- return useQuery({
160
- queryKey: ['users', userId],
161
- queryFn: () => api.users.getUser({ id: userId }),
162
- });
163
- }
164
-
165
- // Mutation hook
166
- function useCreateUser() {
167
- const queryClient = useQueryClient();
168
-
169
- return useMutation({
170
- mutationFn: (data) => api.users.createUser(data),
171
- onSuccess: () => {
172
- // Invalidate and refetch
173
- queryClient.invalidateQueries({ queryKey: ['users'] });
174
- },
175
- });
176
- }
177
-
178
- // In your component
179
- function UserList() {
180
- const { data: users, isLoading, error } = useQuery({
181
- queryKey: ['users'],
182
- queryFn: () => api.users.listUsers({}),
183
- });
184
-
185
- const createUser = useCreateUser();
186
-
187
- const handleCreate = () => {
188
- createUser.mutate({
189
- name: 'New User',
190
- email: 'user@example.com'
191
- });
192
- };
193
-
194
- // ... rest of component
195
- }
196
- ```
197
-
198
- ## Type Inference
199
-
200
- The client uses TypeScript's type system to infer the complete API shape from your backend procedure definitions:
201
-
202
- ```typescript
203
- // Backend (procedures.ts)
204
- export const userProcedures = defineProcedures('users', {
205
- getUser: procedure()
206
- .input(z.object({ id: z.string().uuid() }))
207
- .output(UserSchema)
208
- .query(async ({ input, ctx }) => {
209
- return ctx.db.user.findUnique({ where: { id: input.id } });
210
- }),
35
+ const api = createClient<{ users: typeof userProcedures }>({
36
+ baseUrl: '/api',
211
37
  });
212
38
 
213
- // Frontend - Types are automatically inferred!
214
- const client = createClient<{ users: typeof userProcedures }>({ baseUrl: '/api' });
215
-
216
- // TypeScript knows:
217
- // - api.users.getUser expects { id: string }
218
- // - api.users.getUser returns Promise<User>
219
- // - Invalid inputs will show compile-time errors
220
- ```
221
-
222
- ## REST Endpoint Mapping
223
-
224
- The client automatically maps procedure calls to REST endpoints using the same conventions as the server:
225
-
226
- | Procedure Name | HTTP Method | Path |
227
- |---------------|-------------|------|
228
- | `getUser` | GET | `/users/:id` |
229
- | `listUsers` | GET | `/users` |
230
- | `createUser` | POST | `/users` |
231
- | `updateUser` | PUT | `/users/:id` |
232
- | `deleteUser` | DELETE | `/users/:id` |
233
-
234
- ## Browser and Node.js Support
235
-
236
- The client uses the native `fetch` API, which is available in:
237
- - All modern browsers
238
- - Node.js v20+ (native fetch)
239
- - Earlier Node.js versions with a polyfill
240
-
241
- For older Node.js versions, provide a custom fetch implementation:
242
-
243
- ```typescript
244
- import fetch from 'node-fetch';
245
-
246
- const api = createClient<Router>({
247
- baseUrl: 'https://api.example.com',
248
- fetch: fetch as typeof globalThis.fetch,
249
- });
39
+ const user = await api.users.getUser({ id: '123' });
40
+ // user is fully typed from backend schema
250
41
  ```
251
42
 
252
- ## Related Packages
253
-
254
- - [@veloxts/core](/packages/core) - Core framework with error classes
255
- - [@veloxts/router](/packages/router) - Procedure definitions for backend
256
- - [@veloxts/validation](/packages/validation) - Schema validation with Zod
257
- - [create-velox-app](/packages/create) - Project scaffolder
258
-
259
- ## TypeScript Support
43
+ ## Learn More
260
44
 
261
- All exports are fully typed with comprehensive JSDoc documentation. The package includes type definitions and declaration maps for excellent IDE support.
45
+ - [Full Documentation](./GUIDE.md)
46
+ - [VeloxTS Framework](https://www.npmjs.com/package/@veloxts/velox)
47
+ - [GitHub Repository](https://github.com/veloxts/velox-ts-framework)
262
48
 
263
49
  ## License
264
50
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Unit tests for React hooks (useQuery, useMutation, useQueryClient)
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=hooks.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.test.d.ts","sourceRoot":"","sources":["../../../src/react/__tests__/hooks.test.tsx"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,230 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Unit tests for React hooks (useQuery, useMutation, useQueryClient)
4
+ */
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ import { act, renderHook, waitFor } from '@testing-library/react';
7
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
8
+ import { useMutation, useQuery, useQueryClient } from '../hooks.js';
9
+ import { VeloxProvider } from '../provider.js';
10
+ // Mock client
11
+ const mockGetUser = vi.fn();
12
+ const mockListUsers = vi.fn();
13
+ const mockCreateUser = vi.fn();
14
+ const mockUpdateUser = vi.fn();
15
+ const mockClient = {
16
+ users: {
17
+ getUser: mockGetUser,
18
+ listUsers: mockListUsers,
19
+ createUser: mockCreateUser,
20
+ updateUser: mockUpdateUser,
21
+ },
22
+ };
23
+ // Mock createClient to return our mock client
24
+ vi.mock('../../client.js', () => ({
25
+ createClient: vi.fn(() => mockClient),
26
+ }));
27
+ // Wrapper component for hooks
28
+ function createWrapper() {
29
+ const queryClient = new QueryClient({
30
+ defaultOptions: {
31
+ queries: { retry: false },
32
+ mutations: { retry: false },
33
+ },
34
+ });
35
+ function Wrapper({ children }) {
36
+ return (_jsx(VeloxProvider, { config: { baseUrl: '/api' }, queryClient: queryClient, children: children }));
37
+ }
38
+ return { Wrapper, queryClient };
39
+ }
40
+ // ============================================================================
41
+ // useQuery Tests
42
+ // ============================================================================
43
+ describe('useQuery', () => {
44
+ beforeEach(() => {
45
+ vi.clearAllMocks();
46
+ });
47
+ afterEach(() => {
48
+ vi.clearAllMocks();
49
+ });
50
+ it('fetches data successfully', async () => {
51
+ const mockUser = { id: '123', name: 'Test User', email: 'test@example.com' };
52
+ mockGetUser.mockResolvedValueOnce(mockUser);
53
+ const { Wrapper } = createWrapper();
54
+ const { result } = renderHook(() => useQuery('users', 'getUser', { id: '123' }), { wrapper: Wrapper });
55
+ // Initially loading
56
+ expect(result.current.isLoading).toBe(true);
57
+ // Wait for data
58
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
59
+ expect(result.current.data).toEqual(mockUser);
60
+ expect(mockGetUser).toHaveBeenCalledWith({ id: '123' });
61
+ });
62
+ it('handles errors', async () => {
63
+ const error = new Error('Not found');
64
+ mockGetUser.mockRejectedValueOnce(error);
65
+ const { Wrapper } = createWrapper();
66
+ const { result } = renderHook(() => useQuery('users', 'getUser', { id: 'invalid' }), { wrapper: Wrapper });
67
+ await waitFor(() => expect(result.current.isError).toBe(true));
68
+ expect(result.current.error).toBeDefined();
69
+ expect(result.current.error?.message).toBe('Not found');
70
+ });
71
+ it('respects enabled option', async () => {
72
+ const { Wrapper } = createWrapper();
73
+ const { result } = renderHook(() => useQuery('users', 'getUser', { id: '123' }, { enabled: false }), { wrapper: Wrapper });
74
+ // Should not be loading when disabled
75
+ expect(result.current.isLoading).toBe(false);
76
+ expect(result.current.fetchStatus).toBe('idle');
77
+ expect(mockGetUser).not.toHaveBeenCalled();
78
+ });
79
+ it('refetches on input change', async () => {
80
+ const user1 = { id: '1', name: 'User 1', email: 'user1@example.com' };
81
+ const user2 = { id: '2', name: 'User 2', email: 'user2@example.com' };
82
+ mockGetUser.mockResolvedValueOnce(user1).mockResolvedValueOnce(user2);
83
+ const { Wrapper } = createWrapper();
84
+ const { result, rerender } = renderHook(({ id }) => useQuery('users', 'getUser', { id }), { wrapper: Wrapper, initialProps: { id: '1' } });
85
+ await waitFor(() => expect(result.current.data).toEqual(user1));
86
+ // Change input
87
+ rerender({ id: '2' });
88
+ await waitFor(() => expect(result.current.data).toEqual(user2));
89
+ expect(mockGetUser).toHaveBeenCalledTimes(2);
90
+ });
91
+ });
92
+ // ============================================================================
93
+ // useMutation Tests
94
+ // ============================================================================
95
+ describe('useMutation', () => {
96
+ beforeEach(() => {
97
+ vi.clearAllMocks();
98
+ });
99
+ afterEach(() => {
100
+ vi.clearAllMocks();
101
+ });
102
+ it('executes mutation successfully', async () => {
103
+ const newUser = { id: 'new-id', name: 'New User', email: 'new@example.com' };
104
+ mockCreateUser.mockResolvedValueOnce(newUser);
105
+ const { Wrapper } = createWrapper();
106
+ const { result } = renderHook(() => useMutation('users', 'createUser'), { wrapper: Wrapper });
107
+ expect(result.current.isPending).toBe(false);
108
+ // Execute mutation
109
+ act(() => {
110
+ result.current.mutate({ name: 'New User', email: 'new@example.com' });
111
+ });
112
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
113
+ expect(result.current.data).toEqual(newUser);
114
+ expect(mockCreateUser).toHaveBeenCalledWith({ name: 'New User', email: 'new@example.com' });
115
+ });
116
+ it('handles mutation errors', async () => {
117
+ const error = new Error('Validation failed');
118
+ mockCreateUser.mockRejectedValueOnce(error);
119
+ const { Wrapper } = createWrapper();
120
+ const { result } = renderHook(() => useMutation('users', 'createUser'), { wrapper: Wrapper });
121
+ act(() => {
122
+ result.current.mutate({ name: '', email: 'invalid' });
123
+ });
124
+ await waitFor(() => expect(result.current.isError).toBe(true));
125
+ expect(result.current.error?.message).toBe('Validation failed');
126
+ });
127
+ it('calls onSuccess callback', async () => {
128
+ const newUser = { id: 'new-id', name: 'New User', email: 'new@example.com' };
129
+ mockCreateUser.mockResolvedValueOnce(newUser);
130
+ const onSuccess = vi.fn();
131
+ const { Wrapper } = createWrapper();
132
+ const { result } = renderHook(() => useMutation('users', 'createUser', { onSuccess }), { wrapper: Wrapper });
133
+ act(() => {
134
+ result.current.mutate({ name: 'New User', email: 'new@example.com' });
135
+ });
136
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
137
+ expect(onSuccess).toHaveBeenCalledWith(newUser, { name: 'New User', email: 'new@example.com' }, undefined);
138
+ });
139
+ it('calls onError callback', async () => {
140
+ const error = new Error('Server error');
141
+ mockCreateUser.mockRejectedValueOnce(error);
142
+ const onError = vi.fn();
143
+ const { Wrapper } = createWrapper();
144
+ const { result } = renderHook(() => useMutation('users', 'createUser', { onError }), { wrapper: Wrapper });
145
+ act(() => {
146
+ result.current.mutate({ name: 'Test', email: 'test@example.com' });
147
+ });
148
+ await waitFor(() => expect(result.current.isError).toBe(true));
149
+ expect(onError).toHaveBeenCalled();
150
+ });
151
+ it('supports mutateAsync for promise-based usage', async () => {
152
+ const newUser = { id: 'new-id', name: 'New User', email: 'new@example.com' };
153
+ mockCreateUser.mockResolvedValueOnce(newUser);
154
+ const { Wrapper } = createWrapper();
155
+ const { result } = renderHook(() => useMutation('users', 'createUser'), { wrapper: Wrapper });
156
+ let returnedUser;
157
+ await act(async () => {
158
+ returnedUser = await result.current.mutateAsync({
159
+ name: 'New User',
160
+ email: 'new@example.com',
161
+ });
162
+ });
163
+ expect(returnedUser).toEqual(newUser);
164
+ });
165
+ });
166
+ // ============================================================================
167
+ // useQueryClient Tests
168
+ // ============================================================================
169
+ describe('useQueryClient', () => {
170
+ it('returns the QueryClient instance', () => {
171
+ const { Wrapper, queryClient: expectedClient } = createWrapper();
172
+ const { result } = renderHook(() => useQueryClient(), { wrapper: Wrapper });
173
+ expect(result.current).toBe(expectedClient);
174
+ });
175
+ it('allows manual cache manipulation', async () => {
176
+ const { Wrapper, queryClient } = createWrapper();
177
+ const { result } = renderHook(() => useQueryClient(), { wrapper: Wrapper });
178
+ // Set data manually
179
+ act(() => {
180
+ result.current.setQueryData(['users', 'getUser', { id: '123' }], {
181
+ id: '123',
182
+ name: 'Cached User',
183
+ email: 'cached@example.com',
184
+ });
185
+ });
186
+ const cachedData = queryClient.getQueryData(['users', 'getUser', { id: '123' }]);
187
+ expect(cachedData).toEqual({
188
+ id: '123',
189
+ name: 'Cached User',
190
+ email: 'cached@example.com',
191
+ });
192
+ });
193
+ });
194
+ // ============================================================================
195
+ // Integration Tests
196
+ // ============================================================================
197
+ describe('hooks integration', () => {
198
+ beforeEach(() => {
199
+ vi.clearAllMocks();
200
+ });
201
+ it('mutation onSuccess callback receives correct data', async () => {
202
+ const newUser = { id: '2', name: 'User 2', email: 'user2@example.com' };
203
+ mockCreateUser.mockResolvedValueOnce(newUser);
204
+ const { Wrapper } = createWrapper();
205
+ const onSuccessData = [];
206
+ const { result } = renderHook(() => useMutation('users', 'createUser', {
207
+ onSuccess: (data) => {
208
+ onSuccessData.push(data);
209
+ },
210
+ }), { wrapper: Wrapper });
211
+ // Execute mutation
212
+ act(() => {
213
+ result.current.mutate({ name: 'User 2', email: 'user2@example.com' });
214
+ });
215
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
216
+ // onSuccess should have received the created user
217
+ expect(onSuccessData).toHaveLength(1);
218
+ expect(onSuccessData[0]).toEqual(newUser);
219
+ });
220
+ it('useQueryClient returns a working query client instance', async () => {
221
+ const { Wrapper } = createWrapper();
222
+ const { result } = renderHook(() => useQueryClient(), { wrapper: Wrapper });
223
+ // Should be a QueryClient instance
224
+ expect(result.current).toBeDefined();
225
+ expect(typeof result.current.invalidateQueries).toBe('function');
226
+ expect(typeof result.current.setQueryData).toBe('function');
227
+ expect(typeof result.current.getQueryData).toBe('function');
228
+ });
229
+ });
230
+ //# sourceMappingURL=hooks.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.test.js","sourceRoot":"","sources":["../../../src/react/__tests__/hooks.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MA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E,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAE5E,mCAAmC;QACnC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Unit tests for VeloxProvider component
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=provider.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.test.d.ts","sourceRoot":"","sources":["../../../src/react/__tests__/provider.test.tsx"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Unit tests for VeloxProvider component
4
+ */
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ import { render, screen } from '@testing-library/react';
7
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
8
+ import { useVeloxContext, VeloxProvider } from '../provider.js';
9
+ // ============================================================================
10
+ // Test Setup
11
+ // ============================================================================
12
+ // Mock the createClient function
13
+ vi.mock('../../client.js', () => ({
14
+ createClient: vi.fn((config) => ({
15
+ _config: config,
16
+ users: {
17
+ getUser: vi.fn().mockResolvedValue({ id: '123', name: 'Test User' }),
18
+ },
19
+ })),
20
+ }));
21
+ // Test consumer component that uses the context
22
+ function TestConsumer() {
23
+ const { client } = useVeloxContext();
24
+ return _jsx("div", { "data-testid": "has-client", children: client ? 'Client available' : 'No client' });
25
+ }
26
+ // ============================================================================
27
+ // VeloxProvider Tests
28
+ // ============================================================================
29
+ describe('VeloxProvider', () => {
30
+ let queryClient;
31
+ beforeEach(() => {
32
+ queryClient = new QueryClient({
33
+ defaultOptions: {
34
+ queries: { retry: false },
35
+ },
36
+ });
37
+ });
38
+ afterEach(() => {
39
+ queryClient.clear();
40
+ });
41
+ it('renders children', () => {
42
+ render(_jsx(VeloxProvider, { config: { baseUrl: '/api' }, queryClient: queryClient, children: _jsx("div", { "data-testid": "child", children: "Hello" }) }));
43
+ expect(screen.getByTestId('child')).toHaveTextContent('Hello');
44
+ });
45
+ it('provides client context to children', () => {
46
+ render(_jsx(VeloxProvider, { config: { baseUrl: '/api' }, queryClient: queryClient, children: _jsx(TestConsumer, {}) }));
47
+ expect(screen.getByTestId('has-client')).toHaveTextContent('Client available');
48
+ });
49
+ it('accepts custom QueryClient', () => {
50
+ const customQueryClient = new QueryClient();
51
+ render(_jsx(VeloxProvider, { config: { baseUrl: '/api' }, queryClient: customQueryClient, children: _jsx(TestConsumer, {}) }));
52
+ expect(screen.getByTestId('has-client')).toHaveTextContent('Client available');
53
+ });
54
+ it('creates default QueryClient when not provided', () => {
55
+ render(_jsx(VeloxProvider, { config: { baseUrl: '/api' }, children: _jsx(TestConsumer, {}) }));
56
+ expect(screen.getByTestId('has-client')).toHaveTextContent('Client available');
57
+ });
58
+ });
59
+ // ============================================================================
60
+ // useVeloxContext Tests
61
+ // ============================================================================
62
+ describe('useVeloxContext', () => {
63
+ it('throws when used outside VeloxProvider', () => {
64
+ // Suppress console.error for this test
65
+ const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
66
+ expect(() => {
67
+ render(_jsx(TestConsumer, {}));
68
+ }).toThrow('useVeloxContext must be used within a VeloxProvider');
69
+ consoleSpy.mockRestore();
70
+ });
71
+ it('returns context with client when inside VeloxProvider', () => {
72
+ const queryClient = new QueryClient();
73
+ render(_jsx(VeloxProvider, { config: { baseUrl: '/api' }, queryClient: queryClient, children: _jsx(TestConsumer, {}) }));
74
+ expect(screen.getByTestId('has-client')).toHaveTextContent('Client available');
75
+ });
76
+ });
77
+ //# sourceMappingURL=provider.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.test.js","sourceRoot":"","sources":["../../../src/react/__tests__/provider.test.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEhE,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,iCAAiC;AACjC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,YAAY,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/B,OAAO,EAAE,MAAM;QACf,KAAK,EAAE;YACL,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;SACrE;KACF,CAAC,CAAC;CACJ,CAAC,CAAC,CAAC;AAEJ,gDAAgD;AAChD,SAAS,YAAY;IACnB,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,EAAkD,CAAC;IACrF,OAAO,6BAAiB,YAAY,YAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,GAAO,CAAC;AACzF,CAAC;AAED,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,WAAwB,CAAC;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