|
1 |
| -import { expect, it } from 'vitest' |
| 1 | +import { describe, expect, it } from 'vitest' |
2 | 2 | import { normalizeRoutePath } from '../src/index.js'
|
3 | 3 |
|
4 | 4 | const testCases = [
|
@@ -49,8 +49,39 @@ const testCases = [
|
49 | 49 | ['/foo/.md', '/foo/.html'],
|
50 | 50 | ]
|
51 | 51 |
|
52 |
| -testCases.forEach(([path, expected]) => |
53 |
| - it(`should normalize "${path}" to "${expected}"`, () => { |
54 |
| - expect(normalizeRoutePath(path)).toBe(expected) |
55 |
| - }), |
56 |
| -) |
| 52 | +describe('should normalize clean paths correctly', () => |
| 53 | + testCases.forEach(([path, expected]) => |
| 54 | + it(`"${path}" -> "${expected}"`, () => { |
| 55 | + expect(normalizeRoutePath(path)).toBe(expected) |
| 56 | + }), |
| 57 | + )) |
| 58 | + |
| 59 | +describe('should normalize paths with query correctly', () => |
| 60 | + testCases |
| 61 | + .map(([path, expected]) => [`${path}?foo=bar`, `${expected}?foo=bar`]) |
| 62 | + .forEach(([path, expected]) => |
| 63 | + it(`"${path}" -> "${expected}"`, () => { |
| 64 | + expect(normalizeRoutePath(path)).toBe(expected) |
| 65 | + }), |
| 66 | + )) |
| 67 | + |
| 68 | +describe('should normalize paths with hash correctly', () => |
| 69 | + testCases |
| 70 | + .map(([path, expected]) => [`${path}#foobar`, `${expected}#foobar`]) |
| 71 | + .forEach(([path, expected]) => |
| 72 | + it(`"${path}" -> "${expected}"`, () => { |
| 73 | + expect(normalizeRoutePath(path)).toBe(expected) |
| 74 | + }), |
| 75 | + )) |
| 76 | + |
| 77 | +describe('should normalize paths with query and hash correctly', () => |
| 78 | + testCases |
| 79 | + .map(([path, expected]) => [ |
| 80 | + `${path}?foo=1&bar=2#foobar`, |
| 81 | + `${expected}?foo=1&bar=2#foobar`, |
| 82 | + ]) |
| 83 | + .forEach(([path, expected]) => |
| 84 | + it(`"${path}" -> "${expected}"`, () => { |
| 85 | + expect(normalizeRoutePath(path)).toBe(expected) |
| 86 | + }), |
| 87 | + )) |
0 commit comments