6
6
stringify ,
7
7
pathToRegexp ,
8
8
TokenData ,
9
- ParseError ,
9
+ PathError ,
10
10
} from "./index.js" ;
11
11
import {
12
12
PARSER_TESTS ,
@@ -21,7 +21,7 @@ import {
21
21
describe ( "path-to-regexp" , ( ) => {
22
22
describe ( "ParseError" , ( ) => {
23
23
it ( "should contain original path and debug url" , ( ) => {
24
- const error = new ParseError (
24
+ const error = new PathError (
25
25
"Unexpected END at index 7, expected }" ,
26
26
"/{:foo," ,
27
27
) ;
@@ -34,7 +34,7 @@ describe("path-to-regexp", () => {
34
34
} ) ;
35
35
36
36
it ( "should omit original url when undefined" , ( ) => {
37
- const error = new ParseError (
37
+ const error = new PathError (
38
38
"Unexpected END at index 7, expected }" ,
39
39
undefined ,
40
40
) ;
@@ -50,34 +50,31 @@ describe("path-to-regexp", () => {
50
50
describe ( "parse errors" , ( ) => {
51
51
it ( "should throw on unbalanced group" , ( ) => {
52
52
expect ( ( ) => parse ( "/{:foo," ) ) . toThrow (
53
- new ParseError ( "Unexpected END at index 7, expected }" , "/{:foo," ) ,
53
+ new PathError ( "Unexpected END at index 7, expected }" , "/{:foo," ) ,
54
54
) ;
55
55
} ) ;
56
56
57
57
it ( "should throw on nested unbalanced group" , ( ) => {
58
58
expect ( ( ) => parse ( "/{:foo/{x,y}" ) ) . toThrow (
59
- new ParseError (
60
- "Unexpected END at index 12, expected }" ,
61
- "/{:foo/{x,y}" ,
62
- ) ,
59
+ new PathError ( "Unexpected END at index 12, expected }" , "/{:foo/{x,y}" ) ,
63
60
) ;
64
61
} ) ;
65
62
66
63
it ( "should throw on missing param name" , ( ) => {
67
64
expect ( ( ) => parse ( "/:/" ) ) . toThrow (
68
- new ParseError ( "Missing parameter name at index 2" , "/:/" ) ,
65
+ new PathError ( "Missing parameter name at index 2" , "/:/" ) ,
69
66
) ;
70
67
} ) ;
71
68
72
69
it ( "should throw on missing wildcard name" , ( ) => {
73
70
expect ( ( ) => parse ( "/*/" ) ) . toThrow (
74
- new ParseError ( "Missing parameter name at index 2" , "/*/" ) ,
71
+ new PathError ( "Missing parameter name at index 2" , "/*/" ) ,
75
72
) ;
76
73
} ) ;
77
74
78
75
it ( "should throw on unterminated quote" , ( ) => {
79
76
expect ( ( ) => parse ( '/:"foo' ) ) . toThrow (
80
- new ParseError ( "Unterminated quote at index 2" , '/:"foo' ) ,
77
+ new PathError ( "Unterminated quote at index 2" , '/:"foo' ) ,
81
78
) ;
82
79
} ) ;
83
80
} ) ;
@@ -127,7 +124,7 @@ describe("path-to-regexp", () => {
127
124
describe ( "pathToRegexp errors" , ( ) => {
128
125
it ( "should throw when missing text between params" , ( ) => {
129
126
expect ( ( ) => pathToRegexp ( "/:foo:bar" ) ) . toThrow (
130
- new ParseError ( 'Missing text before "bar" param' , "/:foo:bar" ) ,
127
+ new PathError ( 'Missing text before "bar" param' , "/:foo:bar" ) ,
131
128
) ;
132
129
} ) ;
133
130
@@ -139,7 +136,7 @@ describe("path-to-regexp", () => {
139
136
{ type : "param" , name : "b" } ,
140
137
] ) ,
141
138
) ,
142
- ) . toThrow ( new ParseError ( 'Missing text before "b" param' , undefined ) ) ;
139
+ ) . toThrow ( new PathError ( 'Missing text before "b" param' , undefined ) ) ;
143
140
} ) ;
144
141
145
142
it ( "should throw with `originalPath` when missing text between params using TokenData" , ( ) => {
@@ -153,7 +150,7 @@ describe("path-to-regexp", () => {
153
150
"/[a][b]" ,
154
151
) ,
155
152
) ,
156
- ) . toThrow ( new ParseError ( 'Missing text before "b" param' , "/[a][b]" ) ) ;
153
+ ) . toThrow ( new PathError ( 'Missing text before "b" param' , "/[a][b]" ) ) ;
157
154
} ) ;
158
155
159
156
it ( "should contain the error line" , ( ) => {
0 commit comments