Skip to content

Commit efd66c6

Browse files
committed
Custom separator test
1 parent 9dae1f9 commit efd66c6

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

src/index.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,11 @@ const MATCH_TESTS: MatchTestSet[] = [
25392539
{
25402540
path: "name{/:attr1}?{-:attr2}?{-:attr3}?",
25412541
tests: [
2542+
{
2543+
input: "name",
2544+
matches: ["name", undefined, undefined, undefined],
2545+
expected: { path: "name", index: 0, params: {} },
2546+
},
25422547
{
25432548
input: "name/test",
25442549
matches: ["name/test", "test", undefined, undefined],
@@ -2587,6 +2592,53 @@ const MATCH_TESTS: MatchTestSet[] = [
25872592
},
25882593
],
25892594
},
2595+
{
2596+
path: "name{/:attrs;-}*",
2597+
tests: [
2598+
{
2599+
input: "name",
2600+
matches: ["name", undefined],
2601+
expected: { path: "name", index: 0, params: {} },
2602+
},
2603+
{
2604+
input: "name/1",
2605+
matches: ["name/1", "1"],
2606+
expected: {
2607+
path: "name/1",
2608+
index: 0,
2609+
params: { attrs: ["1"] },
2610+
},
2611+
},
2612+
{
2613+
input: "name/1-2",
2614+
matches: ["name/1-2", "1-2"],
2615+
expected: {
2616+
path: "name/1-2",
2617+
index: 0,
2618+
params: { attrs: ["1", "2"] },
2619+
},
2620+
},
2621+
{
2622+
input: "name/1-2-3",
2623+
matches: ["name/1-2-3", "1-2-3"],
2624+
expected: {
2625+
path: "name/1-2-3",
2626+
index: 0,
2627+
params: { attrs: ["1", "2", "3"] },
2628+
},
2629+
},
2630+
{
2631+
input: "name/foo-bar/route",
2632+
matches: null,
2633+
expected: false,
2634+
},
2635+
{
2636+
input: "name/test/route",
2637+
matches: null,
2638+
expected: false,
2639+
},
2640+
],
2641+
},
25902642

25912643
/**
25922644
* Nested parentheses.

0 commit comments

Comments
 (0)