@@ -120,6 +120,30 @@ responses by hand.`);
120
120
await expect ( result ) . to . have . responseText ( 'Fake file' ) ;
121
121
} ) ;
122
122
123
+ it ( "should regex match requests for a matching full URL" , async ( ) => {
124
+ await server . forGet ( / l o c a l h o s t : \d + \/ [ \w \- ] + .t x t / ) . thenReply ( 200 , 'Fake file' ) ;
125
+
126
+ let result = await fetch ( server . urlFor ( '/matching-file.txt' ) ) ;
127
+
128
+ await expect ( result ) . to . have . responseText ( 'Fake file' ) ;
129
+ } ) ;
130
+
131
+ it ( "should regex match requests for a matching URL with negative regexp -- pass" , async ( ) => {
132
+ await server . forGet ( / ^ (? ! .* l o c a l h o s t ) / ) . thenReply ( 200 , 'Fake file' ) ;
133
+
134
+ let result = await fetch ( server . urlFor ( '/matching-file.txt' ) ) ;
135
+
136
+ await expect ( result ) . to . have . responseText ( 'Fake file' ) ;
137
+ } ) ;
138
+
139
+ it ( "should regex match requests for a matching URL with negative regexp -- catch" , async ( ) => {
140
+ await server . forGet ( ) . withUrlMatching ( / ^ (? ! .* l o c a l h o s t ) / ) . thenReply ( 200 , 'Fake file' ) ;
141
+
142
+ let result2 = await fetch ( server . urlFor ( '/matching-file.txt' ) ) ;
143
+
144
+ await expect ( result2 ) . to . have . responseText ( / ^ .* N o r u l e s * ./ ) ;
145
+ } ) ;
146
+
123
147
it ( "should reject requests for the wrong path" , async ( ) => {
124
148
await server . forGet ( "/specific-endpoint" ) . thenReply ( 200 , "mocked data" ) ;
125
149
@@ -135,6 +159,7 @@ responses by hand.`);
135
159
136
160
expect ( result . status ) . to . equal ( 503 ) ;
137
161
} ) ;
162
+
138
163
139
164
it ( "should match requests ignoring the query string" , async ( ) => {
140
165
await server . forGet ( '/path' ) . thenReply ( 200 , 'Matched path' ) ;
0 commit comments