|
1 | 1 | import { describe, it, assert, test } from 'vitest' |
2 | 2 |
|
3 | | -import { resolvedRouteToObject } from '../compatibles/utils' |
4 | 3 | import { adjustRoutePathForTrailingSlash, getLocaleRouteName, findBrowserLocale } from '../utils' |
5 | 4 |
|
6 | 5 | import type { BrowserLocale } from '../utils' |
@@ -221,288 +220,3 @@ describe('findBrowserLocale', () => { |
221 | 220 | assert.ok(locale === 'ja') |
222 | 221 | }) |
223 | 222 | }) |
224 | | - |
225 | | -describe('resolvedRouteToObject', () => { |
226 | | - it('should map resolved route without special characters', () => { |
227 | | - const expected = { |
228 | | - fullPath: '/ja/about', |
229 | | - hash: '', |
230 | | - query: {}, |
231 | | - name: 'about___ja', |
232 | | - path: '/ja/about', |
233 | | - params: {}, |
234 | | - matched: [ |
235 | | - { |
236 | | - path: '/ja/about', |
237 | | - redirect: undefined, |
238 | | - name: 'about___ja', |
239 | | - meta: {}, |
240 | | - aliasOf: undefined, |
241 | | - beforeEnter: undefined, |
242 | | - props: { |
243 | | - default: false |
244 | | - }, |
245 | | - children: [], |
246 | | - instances: {}, |
247 | | - leaveGuards: {}, |
248 | | - updateGuards: {}, |
249 | | - enterCallbacks: {}, |
250 | | - components: { |
251 | | - default: { |
252 | | - template: '<div>About</div>' |
253 | | - } |
254 | | - } |
255 | | - } |
256 | | - ], |
257 | | - meta: {}, |
258 | | - redirectedFrom: undefined, |
259 | | - href: '/ja/about' |
260 | | - } |
261 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
262 | | - assert.deepEqual(resolvedRouteToObject(expected as any), expected as any) |
263 | | - }) |
264 | | - |
265 | | - it('should map resolved route without special characters and query', () => { |
266 | | - const expected = { |
267 | | - fullPath: '/ja/about?foo=1&test=2', |
268 | | - hash: '', |
269 | | - query: { |
270 | | - foo: '1', |
271 | | - test: '2' |
272 | | - }, |
273 | | - name: 'about___ja', |
274 | | - path: '/ja/about', |
275 | | - params: {}, |
276 | | - matched: [ |
277 | | - { |
278 | | - path: '/ja/about', |
279 | | - redirect: undefined, |
280 | | - name: 'about___ja', |
281 | | - meta: {}, |
282 | | - aliasOf: undefined, |
283 | | - beforeEnter: undefined, |
284 | | - props: { |
285 | | - default: false |
286 | | - }, |
287 | | - children: [], |
288 | | - instances: {}, |
289 | | - leaveGuards: {}, |
290 | | - updateGuards: {}, |
291 | | - enterCallbacks: {}, |
292 | | - components: { |
293 | | - default: { |
294 | | - template: '<div>About</div>' |
295 | | - } |
296 | | - } |
297 | | - } |
298 | | - ], |
299 | | - meta: {}, |
300 | | - redirectedFrom: undefined, |
301 | | - href: '/ja/about?foo=1&test=2' |
302 | | - } |
303 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
304 | | - assert.deepEqual(resolvedRouteToObject(expected as any), expected as any) |
305 | | - }) |
306 | | - |
307 | | - it('should map resolved route without special characters and query with special characters', () => { |
308 | | - const expected = { |
309 | | - fullPath: '/ja/about?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B', |
310 | | - hash: '', |
311 | | - query: { |
312 | | - foo: ['bär', 'bar'], |
313 | | - four: '四' |
314 | | - }, |
315 | | - name: 'about___ja', |
316 | | - path: '/ja/about', |
317 | | - params: {}, |
318 | | - matched: [ |
319 | | - { |
320 | | - path: '/ja/about', |
321 | | - redirect: undefined, |
322 | | - name: 'about___ja', |
323 | | - meta: {}, |
324 | | - aliasOf: undefined, |
325 | | - beforeEnter: undefined, |
326 | | - props: { |
327 | | - default: false |
328 | | - }, |
329 | | - children: [], |
330 | | - instances: {}, |
331 | | - leaveGuards: {}, |
332 | | - updateGuards: {}, |
333 | | - enterCallbacks: {}, |
334 | | - components: { |
335 | | - default: { |
336 | | - template: '<div>About</div>' |
337 | | - } |
338 | | - } |
339 | | - } |
340 | | - ], |
341 | | - meta: {}, |
342 | | - redirectedFrom: undefined, |
343 | | - href: '/ja/about?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B' |
344 | | - } |
345 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
346 | | - assert.deepEqual(resolvedRouteToObject(expected as any), expected as any) |
347 | | - }) |
348 | | - |
349 | | - it('should map resolved route with special characters and query with special characters', () => { |
350 | | - const provided = { |
351 | | - fullPath: '/ja/count/三?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B', |
352 | | - hash: '', |
353 | | - query: { |
354 | | - foo: ['bär', 'bar'], |
355 | | - four: '四' |
356 | | - }, |
357 | | - name: 'count___ja', |
358 | | - path: '/ja/count/三', |
359 | | - params: { |
360 | | - id: '三' |
361 | | - }, |
362 | | - matched: [ |
363 | | - { |
364 | | - path: '/ja/count/:id', |
365 | | - redirect: undefined, |
366 | | - name: 'count___ja', |
367 | | - meta: {}, |
368 | | - aliasOf: undefined, |
369 | | - beforeEnter: undefined, |
370 | | - props: { |
371 | | - default: false |
372 | | - }, |
373 | | - children: [], |
374 | | - instances: {}, |
375 | | - leaveGuards: {}, |
376 | | - updateGuards: {}, |
377 | | - enterCallbacks: {}, |
378 | | - components: { |
379 | | - default: { |
380 | | - template: '<div>Category</div>' |
381 | | - } |
382 | | - } |
383 | | - } |
384 | | - ], |
385 | | - meta: {}, |
386 | | - redirectedFrom: undefined, |
387 | | - href: '/ja/count/%E5%9B%9B?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B' |
388 | | - } |
389 | | - const expected = { |
390 | | - fullPath: '/ja/count/%E4%B8%89?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B', |
391 | | - hash: '', |
392 | | - query: { |
393 | | - foo: ['bär', 'bar'], |
394 | | - four: '四' |
395 | | - }, |
396 | | - name: 'count___ja', |
397 | | - path: '/ja/count/%E4%B8%89', |
398 | | - params: { |
399 | | - id: '三' |
400 | | - }, |
401 | | - matched: [ |
402 | | - { |
403 | | - path: '/ja/count/:id', |
404 | | - redirect: undefined, |
405 | | - name: 'count___ja', |
406 | | - meta: {}, |
407 | | - aliasOf: undefined, |
408 | | - beforeEnter: undefined, |
409 | | - props: { |
410 | | - default: false |
411 | | - }, |
412 | | - children: [], |
413 | | - instances: {}, |
414 | | - leaveGuards: {}, |
415 | | - updateGuards: {}, |
416 | | - enterCallbacks: {}, |
417 | | - components: { |
418 | | - default: { |
419 | | - template: '<div>Category</div>' |
420 | | - } |
421 | | - } |
422 | | - } |
423 | | - ], |
424 | | - meta: {}, |
425 | | - redirectedFrom: undefined, |
426 | | - href: '/ja/count/%E4%B8%89?foo=b%C3%A4r&foo=bar&four=%E5%9B%9B' |
427 | | - } |
428 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
429 | | - assert.deepEqual(resolvedRouteToObject(provided as any), expected as any) |
430 | | - }) |
431 | | - |
432 | | - it('should map resolved route with special characters', () => { |
433 | | - const provided = { |
434 | | - fullPath: '/ja/count/三', |
435 | | - hash: '', |
436 | | - query: {}, |
437 | | - name: 'count___ja', |
438 | | - path: '/ja/count/三', |
439 | | - params: { |
440 | | - id: '三' |
441 | | - }, |
442 | | - matched: [ |
443 | | - { |
444 | | - path: '/ja/count/:id', |
445 | | - redirect: undefined, |
446 | | - name: 'count___ja', |
447 | | - meta: {}, |
448 | | - aliasOf: undefined, |
449 | | - beforeEnter: undefined, |
450 | | - props: { |
451 | | - default: false |
452 | | - }, |
453 | | - children: [], |
454 | | - instances: {}, |
455 | | - leaveGuards: {}, |
456 | | - updateGuards: {}, |
457 | | - enterCallbacks: {}, |
458 | | - components: { |
459 | | - default: { |
460 | | - template: '<div>Category</div>' |
461 | | - } |
462 | | - } |
463 | | - } |
464 | | - ], |
465 | | - meta: {}, |
466 | | - redirectedFrom: undefined, |
467 | | - href: '/ja/count/三' |
468 | | - } |
469 | | - const expected = { |
470 | | - fullPath: '/ja/count/%E4%B8%89', |
471 | | - hash: '', |
472 | | - query: {}, |
473 | | - name: 'count___ja', |
474 | | - path: '/ja/count/%E4%B8%89', |
475 | | - params: { |
476 | | - id: '三' |
477 | | - }, |
478 | | - matched: [ |
479 | | - { |
480 | | - path: '/ja/count/:id', |
481 | | - redirect: undefined, |
482 | | - name: 'count___ja', |
483 | | - meta: {}, |
484 | | - aliasOf: undefined, |
485 | | - beforeEnter: undefined, |
486 | | - props: { |
487 | | - default: false |
488 | | - }, |
489 | | - children: [], |
490 | | - instances: {}, |
491 | | - leaveGuards: {}, |
492 | | - updateGuards: {}, |
493 | | - enterCallbacks: {}, |
494 | | - components: { |
495 | | - default: { |
496 | | - template: '<div>Category</div>' |
497 | | - } |
498 | | - } |
499 | | - } |
500 | | - ], |
501 | | - meta: {}, |
502 | | - redirectedFrom: undefined, |
503 | | - href: '/ja/count/%E4%B8%89' |
504 | | - } |
505 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
506 | | - assert.deepEqual(resolvedRouteToObject(provided as any), expected as any) |
507 | | - }) |
508 | | -}) |
0 commit comments