@storybook/tanstack-react 10.6.0-alpha.0 → 10.6.0-alpha.2
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/dist/_browser-chunks/{chunk-WQHJSC2D.js → chunk-FF4C4TUQ.js} +51 -9
- package/dist/_browser-chunks/{chunk-XKNIZ3MM.js → chunk-LTDGLEVR.js} +9 -1
- package/dist/chunk-B2-fTWlC.d.ts +131 -0
- package/dist/export-mocks/react-router.d.ts +294 -291
- package/dist/export-mocks/react-router.js +16 -12
- package/dist/export-mocks/start-storage-context.d.ts +12 -10
- package/dist/export-mocks/start.d.ts +61 -49
- package/dist/export-mocks/start.js +3 -2
- package/dist/index.d.ts +54 -186
- package/dist/index.js +2 -2
- package/dist/node/index.d.ts +4 -26
- package/dist/node/index.js +6 -6
- package/dist/preset.d.ts +5 -4
- package/dist/preset.js +16 -7
- package/dist/preview.d.ts +6 -106
- package/dist/preview.js +2 -2
- package/package.json +6 -6
- package/template/stories/PathlessLayout.stories.tsx +150 -0
|
@@ -1,147 +1,145 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
export * from
|
|
4
|
-
import * as _tanstack_router_core from '@tanstack/router-core';
|
|
5
|
-
import React from 'react';
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Navigate as Navigate$1, useBlocker as useBlocker$1, useCanGoBack as useCanGoBack$1, useLinkProps as useLinkProps$1, useLoaderData as useLoaderData$1, useLoaderDeps as useLoaderDeps$1, useLocation as useLocation$1, useNavigate as useNavigate$1, useParams as useParams$1, useRouteContext as useRouteContext$1, useRouter as useRouter$1, useRouterState as useRouterState$1, useSearch as useSearch$1 } from "@tanstack/react-router";
|
|
3
|
+
export * from "@tanstack/react-router";
|
|
6
4
|
|
|
5
|
+
//#region node_modules/@vitest/spy/dist/index.d.ts
|
|
7
6
|
interface MockResultReturn<T> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
type: "return";
|
|
8
|
+
/**
|
|
9
|
+
* The value that was returned from the function. If function returned a Promise, then this will be a resolved value.
|
|
10
|
+
*/
|
|
11
|
+
value: T;
|
|
13
12
|
}
|
|
14
13
|
interface MockResultIncomplete {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
type: "incomplete";
|
|
15
|
+
value: undefined;
|
|
17
16
|
}
|
|
18
17
|
interface MockResultThrow {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
type: "throw";
|
|
19
|
+
/**
|
|
20
|
+
* An error that was thrown during function execution.
|
|
21
|
+
*/
|
|
22
|
+
value: any;
|
|
24
23
|
}
|
|
25
24
|
interface MockSettledResultFulfilled<T> {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
type: "fulfilled";
|
|
26
|
+
value: T;
|
|
28
27
|
}
|
|
29
28
|
interface MockSettledResultRejected {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
type: "rejected";
|
|
30
|
+
value: any;
|
|
32
31
|
}
|
|
33
32
|
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
|
34
33
|
type MockSettledResult<T> = MockSettledResultFulfilled<T> | MockSettledResultRejected;
|
|
35
34
|
interface MockContext<T extends Procedure> {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
35
|
+
/**
|
|
36
|
+
* This is an array containing all arguments for each call. One item of the array is the arguments of that call.
|
|
37
|
+
*
|
|
38
|
+
* @see https://vitest.dev/api/mock#mock-calls
|
|
39
|
+
* @example
|
|
40
|
+
* const fn = vi.fn()
|
|
41
|
+
*
|
|
42
|
+
* fn('arg1', 'arg2')
|
|
43
|
+
* fn('arg3')
|
|
44
|
+
*
|
|
45
|
+
* fn.mock.calls === [
|
|
46
|
+
* ['arg1', 'arg2'], // first call
|
|
47
|
+
* ['arg3'], // second call
|
|
48
|
+
* ]
|
|
49
|
+
*/
|
|
50
|
+
calls: Parameters<T>[];
|
|
51
|
+
/**
|
|
52
|
+
* This is an array containing all instances that were instantiated when mock was called with a `new` keyword. Note that this is an actual context (`this`) of the function, not a return value.
|
|
53
|
+
* @see https://vitest.dev/api/mock#mock-instances
|
|
54
|
+
*/
|
|
55
|
+
instances: ReturnType<T>[];
|
|
56
|
+
/**
|
|
57
|
+
* An array of `this` values that were used during each call to the mock function.
|
|
58
|
+
* @see https://vitest.dev/api/mock#mock-contexts
|
|
59
|
+
*/
|
|
60
|
+
contexts: ThisParameterType<T>[];
|
|
61
|
+
/**
|
|
62
|
+
* The order of mock's execution. This returns an array of numbers which are shared between all defined mocks.
|
|
63
|
+
*
|
|
64
|
+
* @see https://vitest.dev/api/mock#mock-invocationcallorder
|
|
65
|
+
* @example
|
|
66
|
+
* const fn1 = vi.fn()
|
|
67
|
+
* const fn2 = vi.fn()
|
|
68
|
+
*
|
|
69
|
+
* fn1()
|
|
70
|
+
* fn2()
|
|
71
|
+
* fn1()
|
|
72
|
+
*
|
|
73
|
+
* fn1.mock.invocationCallOrder === [1, 3]
|
|
74
|
+
* fn2.mock.invocationCallOrder === [2]
|
|
75
|
+
*/
|
|
76
|
+
invocationCallOrder: number[];
|
|
77
|
+
/**
|
|
78
|
+
* This is an array containing all values that were `returned` from the function.
|
|
79
|
+
*
|
|
80
|
+
* The `value` property contains the returned value or thrown error. If the function returned a `Promise`, then `result` will always be `'return'` even if the promise was rejected.
|
|
81
|
+
*
|
|
82
|
+
* @see https://vitest.dev/api/mock#mock-results
|
|
83
|
+
* @example
|
|
84
|
+
* const fn = vi.fn()
|
|
85
|
+
* .mockReturnValueOnce('result')
|
|
86
|
+
* .mockImplementationOnce(() => { throw new Error('thrown error') })
|
|
87
|
+
*
|
|
88
|
+
* const result = fn()
|
|
89
|
+
*
|
|
90
|
+
* try {
|
|
91
|
+
* fn()
|
|
92
|
+
* }
|
|
93
|
+
* catch {}
|
|
94
|
+
*
|
|
95
|
+
* fn.mock.results === [
|
|
96
|
+
* {
|
|
97
|
+
* type: 'return',
|
|
98
|
+
* value: 'result',
|
|
99
|
+
* },
|
|
100
|
+
* {
|
|
101
|
+
* type: 'throw',
|
|
102
|
+
* value: Error,
|
|
103
|
+
* },
|
|
104
|
+
* ]
|
|
105
|
+
*/
|
|
106
|
+
results: MockResult<ReturnType<T>>[];
|
|
107
|
+
/**
|
|
108
|
+
* An array containing all values that were `resolved` or `rejected` from the function.
|
|
109
|
+
*
|
|
110
|
+
* This array will be empty if the function was never resolved or rejected.
|
|
111
|
+
*
|
|
112
|
+
* @see https://vitest.dev/api/mock#mock-settledresults
|
|
113
|
+
* @example
|
|
114
|
+
* const fn = vi.fn().mockResolvedValueOnce('result')
|
|
115
|
+
*
|
|
116
|
+
* const result = fn()
|
|
117
|
+
*
|
|
118
|
+
* fn.mock.settledResults === []
|
|
119
|
+
* fn.mock.results === [
|
|
120
|
+
* {
|
|
121
|
+
* type: 'return',
|
|
122
|
+
* value: Promise<'result'>,
|
|
123
|
+
* },
|
|
124
|
+
* ]
|
|
125
|
+
*
|
|
126
|
+
* await result
|
|
127
|
+
*
|
|
128
|
+
* fn.mock.settledResults === [
|
|
129
|
+
* {
|
|
130
|
+
* type: 'fulfilled',
|
|
131
|
+
* value: 'result',
|
|
132
|
+
* },
|
|
133
|
+
* ]
|
|
134
|
+
*/
|
|
135
|
+
settledResults: MockSettledResult<Awaited<ReturnType<T>>>[];
|
|
136
|
+
/**
|
|
137
|
+
* This contains the arguments of the last call. If spy wasn't called, will return `undefined`.
|
|
138
|
+
* @see https://vitest.dev/api/mock#mock-lastcall
|
|
139
|
+
*/
|
|
140
|
+
lastCall: Parameters<T> | undefined;
|
|
142
141
|
}
|
|
143
|
-
type Procedure = (...args: any[]) => any;
|
|
144
|
-
// pick a single function type from function overloads, unions, etc...
|
|
142
|
+
type Procedure = (...args: any[]) => any; // pick a single function type from function overloads, unions, etc...
|
|
145
143
|
type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
|
|
146
144
|
/*
|
|
147
145
|
cf. https://typescript-eslint.io/rules/method-signature-style/
|
|
@@ -156,163 +154,164 @@ const boolFn: Jest.Mock<() => boolean> = jest.fn<() => true>(() => true)
|
|
|
156
154
|
*/
|
|
157
155
|
/* eslint-disable ts/method-signature-style */
|
|
158
156
|
interface MockInstance<T extends Procedure = Procedure> extends Disposable {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Use it to return the name assigned to the mock with the `.mockName(name)` method. By default, it will return `vi.fn()`.
|
|
159
|
+
* @see https://vitest.dev/api/mock#getmockname
|
|
160
|
+
*/
|
|
161
|
+
getMockName(): string;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the internal mock name. This is useful for identifying the mock when an assertion fails.
|
|
164
|
+
* @see https://vitest.dev/api/mock#mockname
|
|
165
|
+
*/
|
|
166
|
+
mockName(name: string): this;
|
|
167
|
+
/**
|
|
168
|
+
* Current context of the mock. It stores information about all invocation calls, instances, and results.
|
|
169
|
+
*/
|
|
170
|
+
mock: MockContext<T>;
|
|
171
|
+
/**
|
|
172
|
+
* Clears all information about every call. After calling it, all properties on `.mock` will return to their initial state. This method does not reset implementations. It is useful for cleaning up mocks between different assertions.
|
|
173
|
+
*
|
|
174
|
+
* To automatically call this method before each test, enable the [`clearMocks`](https://vitest.dev/config/#clearmocks) setting in the configuration.
|
|
175
|
+
* @see https://vitest.dev/api/mock#mockclear
|
|
176
|
+
*/
|
|
177
|
+
mockClear(): this;
|
|
178
|
+
/**
|
|
179
|
+
* Does what `mockClear` does and resets inner implementation to the original function. This also resets all "once" implementations.
|
|
180
|
+
*
|
|
181
|
+
* Note that resetting a mock from `vi.fn()` will set implementation to an empty function that returns `undefined`.
|
|
182
|
+
* Resetting a mock from `vi.fn(impl)` will set implementation to `impl`. It is useful for completely resetting a mock to its default state.
|
|
183
|
+
*
|
|
184
|
+
* To automatically call this method before each test, enable the [`mockReset`](https://vitest.dev/config/#mockreset) setting in the configuration.
|
|
185
|
+
* @see https://vitest.dev/api/mock#mockreset
|
|
186
|
+
*/
|
|
187
|
+
mockReset(): this;
|
|
188
|
+
/**
|
|
189
|
+
* Does what `mockReset` does and restores original descriptors of spied-on objects.
|
|
190
|
+
*
|
|
191
|
+
* Note that restoring mock from `vi.fn()` will set implementation to an empty function that returns `undefined`. Restoring a `vi.fn(impl)` will restore implementation to `impl`.
|
|
192
|
+
* @see https://vitest.dev/api/mock#mockrestore
|
|
193
|
+
*/
|
|
194
|
+
mockRestore(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Returns current permanent mock implementation if there is one.
|
|
197
|
+
*
|
|
198
|
+
* If mock was created with `vi.fn`, it will consider passed down method as a mock implementation.
|
|
199
|
+
*
|
|
200
|
+
* If mock was created with `vi.spyOn`, it will return `undefined` unless a custom implementation was provided.
|
|
201
|
+
*/
|
|
202
|
+
getMockImplementation(): NormalizedProcedure<T> | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function.
|
|
205
|
+
* @see https://vitest.dev/api/mock#mockimplementation
|
|
206
|
+
* @example
|
|
207
|
+
* const increment = vi.fn().mockImplementation(count => count + 1);
|
|
208
|
+
* expect(increment(3)).toBe(4);
|
|
209
|
+
*/
|
|
210
|
+
mockImplementation(fn: NormalizedProcedure<T>): this;
|
|
211
|
+
/**
|
|
212
|
+
* Accepts a function to be used as the mock implementation. TypeScript expects the arguments and return type to match those of the original function. This method can be chained to produce different results for multiple function calls.
|
|
213
|
+
*
|
|
214
|
+
* When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
|
|
215
|
+
* @see https://vitest.dev/api/mock#mockimplementationonce
|
|
216
|
+
* @example
|
|
217
|
+
* const fn = vi.fn(count => count).mockImplementationOnce(count => count + 1);
|
|
218
|
+
* expect(fn(3)).toBe(4);
|
|
219
|
+
* expect(fn(3)).toBe(3);
|
|
220
|
+
*/
|
|
221
|
+
mockImplementationOnce(fn: NormalizedProcedure<T>): this;
|
|
222
|
+
/**
|
|
223
|
+
* Overrides the original mock implementation temporarily while the callback is being executed.
|
|
224
|
+
*
|
|
225
|
+
* Note that this method takes precedence over the [`mockImplementationOnce`](https://vitest.dev/api/mock#mockimplementationonce).
|
|
226
|
+
* @see https://vitest.dev/api/mock#withimplementation
|
|
227
|
+
* @example
|
|
228
|
+
* const myMockFn = vi.fn(() => 'original')
|
|
229
|
+
*
|
|
230
|
+
* myMockFn.withImplementation(() => 'temp', () => {
|
|
231
|
+
* myMockFn() // 'temp'
|
|
232
|
+
* })
|
|
233
|
+
*
|
|
234
|
+
* myMockFn() // 'original'
|
|
235
|
+
*/
|
|
236
|
+
withImplementation<T2>(fn: NormalizedProcedure<T>, cb: () => T2): T2 extends Promise<unknown> ? Promise<this> : this;
|
|
237
|
+
/**
|
|
238
|
+
* Use this if you need to return the `this` context from the method without invoking the actual implementation.
|
|
239
|
+
* @see https://vitest.dev/api/mock#mockreturnthis
|
|
240
|
+
*/
|
|
241
|
+
mockReturnThis(): this;
|
|
242
|
+
/**
|
|
243
|
+
* Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
|
|
244
|
+
* @see https://vitest.dev/api/mock#mockreturnvalue
|
|
245
|
+
* @example
|
|
246
|
+
* const mock = vi.fn()
|
|
247
|
+
* mock.mockReturnValue(42)
|
|
248
|
+
* mock() // 42
|
|
249
|
+
* mock.mockReturnValue(43)
|
|
250
|
+
* mock() // 43
|
|
251
|
+
*/
|
|
252
|
+
mockReturnValue(value: ReturnType<T>): this;
|
|
253
|
+
/**
|
|
254
|
+
* Accepts a value that will be returned whenever the mock function is called. TypeScript will only accept values that match the return type of the original function.
|
|
255
|
+
*
|
|
256
|
+
* When the mocked function runs out of implementations, it will invoke the default implementation set with `vi.fn(() => defaultValue)` or `.mockImplementation(() => defaultValue)` if they were called.
|
|
257
|
+
* @example
|
|
258
|
+
* const myMockFn = vi
|
|
259
|
+
* .fn()
|
|
260
|
+
* .mockReturnValue('default')
|
|
261
|
+
* .mockReturnValueOnce('first call')
|
|
262
|
+
* .mockReturnValueOnce('second call')
|
|
263
|
+
*
|
|
264
|
+
* // 'first call', 'second call', 'default'
|
|
265
|
+
* console.log(myMockFn(), myMockFn(), myMockFn())
|
|
266
|
+
*/
|
|
267
|
+
mockReturnValueOnce(value: ReturnType<T>): this;
|
|
268
|
+
/**
|
|
269
|
+
* Accepts a value that will be resolved when the async function is called. TypeScript will only accept values that match the return type of the original function.
|
|
270
|
+
* @example
|
|
271
|
+
* const asyncMock = vi.fn().mockResolvedValue(42)
|
|
272
|
+
* asyncMock() // Promise<42>
|
|
273
|
+
*/
|
|
274
|
+
mockResolvedValue(value: Awaited<ReturnType<T>>): this;
|
|
275
|
+
/**
|
|
276
|
+
* Accepts a value that will be resolved during the next function call. TypeScript will only accept values that match the return type of the original function. If chained, each consecutive call will resolve the specified value.
|
|
277
|
+
* @example
|
|
278
|
+
* const myMockFn = vi
|
|
279
|
+
* .fn()
|
|
280
|
+
* .mockResolvedValue('default')
|
|
281
|
+
* .mockResolvedValueOnce('first call')
|
|
282
|
+
* .mockResolvedValueOnce('second call')
|
|
283
|
+
*
|
|
284
|
+
* // Promise<'first call'>, Promise<'second call'>, Promise<'default'>
|
|
285
|
+
* console.log(myMockFn(), myMockFn(), myMockFn())
|
|
286
|
+
*/
|
|
287
|
+
mockResolvedValueOnce(value: Awaited<ReturnType<T>>): this;
|
|
288
|
+
/**
|
|
289
|
+
* Accepts an error that will be rejected when async function is called.
|
|
290
|
+
* @example
|
|
291
|
+
* const asyncMock = vi.fn().mockRejectedValue(new Error('Async error'))
|
|
292
|
+
* await asyncMock() // throws Error<'Async error'>
|
|
293
|
+
*/
|
|
294
|
+
mockRejectedValue(error: unknown): this;
|
|
295
|
+
/**
|
|
296
|
+
* Accepts a value that will be rejected during the next function call. If chained, each consecutive call will reject the specified value.
|
|
297
|
+
* @example
|
|
298
|
+
* const asyncMock = vi
|
|
299
|
+
* .fn()
|
|
300
|
+
* .mockResolvedValueOnce('first call')
|
|
301
|
+
* .mockRejectedValueOnce(new Error('Async error'))
|
|
302
|
+
*
|
|
303
|
+
* await asyncMock() // first call
|
|
304
|
+
* await asyncMock() // throws Error<'Async error'>
|
|
305
|
+
*/
|
|
306
|
+
mockRejectedValueOnce(error: unknown): this;
|
|
309
307
|
}
|
|
310
308
|
/* eslint-enable ts/method-signature-style */
|
|
311
309
|
interface Mock<T extends Procedure = Procedure> extends MockInstance<T> {
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
new (...args: Parameters<T>): ReturnType<T>;
|
|
311
|
+
(...args: Parameters<T>): ReturnType<T>;
|
|
314
312
|
}
|
|
315
|
-
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region code/frameworks/tanstack-react/.dts-emit/code/frameworks/tanstack-react/src/export-mocks/react-router.d.ts
|
|
316
315
|
declare const useNavigate: Mock<typeof useNavigate$1>;
|
|
317
316
|
declare const useRouter: Mock<typeof useRouter$1>;
|
|
318
317
|
declare const useBlocker: Mock<typeof useBlocker$1>;
|
|
@@ -326,18 +325,22 @@ declare const useRouteContext: Mock<typeof useRouteContext$1>;
|
|
|
326
325
|
declare const useCanGoBack: Mock<typeof useCanGoBack$1>;
|
|
327
326
|
declare const useLinkProps: Mock<typeof useLinkProps$1>;
|
|
328
327
|
declare const Navigate: typeof Navigate$1;
|
|
329
|
-
declare const Link: ({
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
328
|
+
declare const Link: ({
|
|
329
|
+
to,
|
|
330
|
+
children,
|
|
331
|
+
...props
|
|
332
|
+
}: {
|
|
333
|
+
to: string;
|
|
334
|
+
children?: React.ReactNode;
|
|
335
|
+
[key: string]: unknown;
|
|
333
336
|
}) => React.DetailedReactHTMLElement<{
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
href: string;
|
|
338
|
+
onClick: (e: React.MouseEvent) => void;
|
|
336
339
|
}, HTMLElement>;
|
|
337
340
|
/**
|
|
338
341
|
* Override createFileRoute from tanstack react router
|
|
339
342
|
* because the org `createFileRoute` doesn't set the path in the Route
|
|
340
343
|
*/
|
|
341
|
-
declare function createFileRoute(path: string): (options: any) =>
|
|
342
|
-
|
|
343
|
-
export { Link, Navigate, createFileRoute, useBlocker, useCanGoBack, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
|
|
344
|
+
declare function createFileRoute(path: string): (options: any) => import("@tanstack/react-router").Route<unknown, import("@tanstack/router-core").AnyRoute, "/", "/" | `/${any}/`, string, "/" | `/${any}/`, undefined, import("@tanstack/router-core").ResolveParams<"/">, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
345
|
+
//#endregion
|
|
346
|
+
export { Link, Navigate, createFileRoute, useBlocker, useCanGoBack, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
|