@@ -23,11 +23,11 @@ describe("Mockttp explanation messages", function () {
2323 let responseText = await response . text ( ) ;
2424
2525 expect ( responseText ) . to . include ( `
26- Match requests making GETs for /endpoint, and then respond with status 200 and body "1", once (seen 0).
27- Match requests making GETs for /endpoint, and then respond with status 200 and body "2/3", twice (seen 0).
28- Match requests making GETs for /endpoint, and then respond with status 200 and body "4/5/6", thrice (seen 0).
29- Match requests making GETs for /endpoint, and then respond with status 200 and body "7/8/9/10", 4 times (seen 0).
30- Match requests making GETs for /endpoint, and then respond with status 200 and body "forever", always (seen 0).
26+ Match requests making GETs for /endpoint, and respond with status 200 and body "1", once (seen 0).
27+ Match requests making GETs for /endpoint, and respond with status 200 and body "2/3", twice (seen 0).
28+ Match requests making GETs for /endpoint, and respond with status 200 and body "4/5/6", thrice (seen 0).
29+ Match requests making GETs for /endpoint, and respond with status 200 and body "7/8/9/10", 4 times (seen 0).
30+ Match requests making GETs for /endpoint, and respond with status 200 and body "forever", always (seen 0).
3131` ) ;
3232 } ) ;
3333
@@ -46,11 +46,11 @@ Match requests making GETs for /endpoint, and then respond with status 200 and b
4646 let responseText = await response . text ( ) ;
4747
4848 expect ( responseText ) . to . include ( `
49- Match requests making GETs for /endpoint, and then respond with status 200 and body "1", once (done).
50- Match requests making GETs for /endpoint, and then respond with status 200 and body "2/3", twice (done).
51- Match requests making GETs for /endpoint, and then respond with status 200 and body "4/5/6", thrice (done).
52- Match requests making GETs for /endpoint, and then respond with status 200 and body "7/8/9/10", 4 times (seen 2).
53- Match requests making GETs for /endpoint, and then respond with status 200 and body "forever", always (seen 0).
49+ Match requests making GETs for /endpoint, and respond with status 200 and body "1", once (done).
50+ Match requests making GETs for /endpoint, and respond with status 200 and body "2/3", twice (done).
51+ Match requests making GETs for /endpoint, and respond with status 200 and body "4/5/6", thrice (done).
52+ Match requests making GETs for /endpoint, and respond with status 200 and body "7/8/9/10", 4 times (seen 2).
53+ Match requests making GETs for /endpoint, and respond with status 200 and body "forever", always (seen 0).
5454` ) ;
5555 } ) ;
5656
@@ -62,6 +62,7 @@ Match requests making GETs for /endpoint, and then respond with status 200 and b
6262 await server . forPut ( "/endpointD" ) . withQuery ( { a : 1 } ) . always ( ) . thenCloseConnection ( ) ;
6363 await server . forPut ( "/endpointE" ) . forHost ( 'abc.com' ) . withExactQuery ( '?' ) . thenTimeout ( ) ;
6464 await server . forAnyWebSocket ( ) . thenForwardTo ( "google.com" ) ;
65+ await server . forUnmatchedRequest ( ) . withBody ( "b" ) . delay ( 100 ) . thenReply ( 200 ) ;
6566
6667 await fetch ( server . urlFor ( "/endpointA/123" ) ) ;
6768 let response = await fetch ( server . urlFor ( "/non-existent-endpoint" ) ) ;
@@ -70,13 +71,14 @@ Match requests making GETs for /endpoint, and then respond with status 200 and b
7071
7172 expect ( text ) . to . include ( `No rules were found matching this request.` ) ;
7273 expect ( text ) . to . include ( `The configured rules are:
73- Match requests for anything with headers including {"h":"v"}, and then respond with status 200 and a stream of response data.
74- Match requests making GETs matching //endpointA/\\d+/, and then respond with status 200 and body "nice request!", once (done).
75- Match requests making POSTs, for /endpointB, and with form data including {"key":"value"}, and then respond with status 500.
76- Match requests making POSTs, for /endpointC, and with a JSON body equivalent to {"key":"value"}, and then respond with status 500.
77- Match requests making PUTs, for /endpointD, and with a query including {"a":"1"}, and then close the connection, always (seen 0).
78- Match requests making PUTs, for /endpointE, for host abc.com, and with a query exactly matching \`?\`, and then time out (never respond).
79- Match websockets for anything, and then forward the websocket to google.com.
74+ Match otherwise unmatched requests for anything with body 'b', and wait 100ms, then respond with status 200.
75+ Match requests for anything with headers including {"h":"v"}, and respond with status 200 and a stream of response data.
76+ Match requests making GETs matching //endpointA/\\d+/, and respond with status 200 and body "nice request!", once (done).
77+ Match requests making POSTs, for /endpointB, and with form data including {"key":"value"}, and respond with status 500.
78+ Match requests making POSTs, for /endpointC, and with a JSON body equivalent to {"key":"value"}, and respond with status 500.
79+ Match requests making PUTs, for /endpointD, and with a query including {"a":"1"}, and close the connection, always (seen 0).
80+ Match requests making PUTs, for /endpointE, for host abc.com, and with a query exactly matching \`?\`, and time out (never respond).
81+ Match websockets for anything, and forward the websocket to google.com.
8082` ) ;
8183 } ) ;
8284
@@ -88,8 +90,8 @@ Match websockets for anything, and then forward the websocket to google.com.
8890 let text = await response . text ( ) ;
8991
9092 expect ( text ) . to . include ( `The configured rules are:
91- Match requests making POSTs for /endpointA, and then respond using provided callback.
92- Match requests making POSTs for /endpointB, and then respond using provided callback (handleRequest).
93+ Match requests making POSTs for /endpointA, and respond using provided callback.
94+ Match requests making POSTs for /endpointB, and respond using provided callback (handleRequest).
9395` ) ;
9496 } ) ;
9597
@@ -180,16 +182,16 @@ as a proxy, instead of making requests to it directly`);
180182 const util = require ( 'util' ) ;
181183 const explanation = util . inspect ( endpoints ) ;
182184 expect ( explanation ) . to . include (
183- 'Match requests making GETs for /endpoint, and then respond with status 200 and body "first response", twice (seen 1).'
185+ 'Match requests making GETs for /endpoint, and respond with status 200 and body "first response", twice (seen 1).'
184186 ) ;
185187 expect ( explanation ) . to . include (
186- 'Match requests making GETs for /endpoint, and then respond with status 200 and body "second response".'
188+ 'Match requests making GETs for /endpoint, and respond with status 200 and body "second response".'
187189 ) ;
188190 } else {
189191 const explanations = endpoints . map ( p => ( p as any ) . explanation ) ;
190192 expect ( explanations ) . to . deep . equal ( [
191- 'Match requests making GETs for /endpoint, and then respond with status 200 and body "first response", twice.' ,
192- 'Match requests making GETs for /endpoint, and then respond with status 200 and body "second response".'
193+ 'Match requests making GETs for /endpoint, and respond with status 200 and body "first response", twice.' ,
194+ 'Match requests making GETs for /endpoint, and respond with status 200 and body "second response".'
193195 ] ) ;
194196 }
195197 } ) ;
0 commit comments