@@ -120,6 +120,30 @@ responses by hand.`);
120120 await expect ( result ) . to . have . responseText ( 'Fake file' ) ;
121121 } ) ;
122122
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+
123147 it ( "should reject requests for the wrong path" , async ( ) => {
124148 await server . forGet ( "/specific-endpoint" ) . thenReply ( 200 , "mocked data" ) ;
125149
@@ -135,6 +159,7 @@ responses by hand.`);
135159
136160 expect ( result . status ) . to . equal ( 503 ) ;
137161 } ) ;
162+
138163
139164 it ( "should match requests ignoring the query string" , async ( ) => {
140165 await server . forGet ( '/path' ) . thenReply ( 200 , 'Matched path' ) ;
0 commit comments