@@ -136,6 +136,45 @@ class CustomRouteTests: ShockTestCase {
136
136
self . waitForExpectations ( timeout: timeout, handler: nil )
137
137
}
138
138
139
+ func testCustomRouteWithDynamicQueryParameters( ) {
140
+ let query = " item1=value1&item2=value2 "
141
+ let route : MockHTTPRoute = . custom(
142
+ method: . get,
143
+ urlPath: " /custom-with-query " ,
144
+ query: [ " item1 " : " :placeHolder1 " , " item2 " : " :placeHolder2 " ] ,
145
+ requestHeaders: [ : ] ,
146
+ responseHeaders: [ : ] ,
147
+ code: 200 ,
148
+ filename: " testCustomRoute.txt "
149
+ )
150
+ let query2 = " item3=value3&item4=value4 "
151
+ let route2 : MockHTTPRoute = . custom(
152
+ method: . get,
153
+ urlPath: " /custom-with-query " ,
154
+ query: [ " item3 " : " :placeHolder3 " , " item4 " : " :placeHolder4 " ] ,
155
+ requestHeaders: [ : ] ,
156
+ responseHeaders: [ : ] ,
157
+ code: 200 ,
158
+ filename: " testCustomRoute2.txt "
159
+ )
160
+ let routes : MockHTTPRoute = . collection( routes: [ route, route2] )
161
+ server. setup ( route: routes)
162
+
163
+ let expectation = self . expectation ( description: " Expect 200 response with response body " )
164
+ HTTPClient . get ( url: " \( server. hostURL) /custom-with-query? \( query) " ) { code, body, headers, error in
165
+ expectation. fulfill ( )
166
+ XCTAssertEqual ( code, 200 )
167
+ XCTAssertEqual ( body, " testCustomRoute test fixture \n " )
168
+ }
169
+ let expectation2 = self . expectation ( description: " Expect 200 response with response body " )
170
+ HTTPClient . get ( url: " \( server. hostURL) /custom-with-query? \( query2) " ) { code, body, headers, error in
171
+ expectation2. fulfill ( )
172
+ XCTAssertEqual ( code, 200 )
173
+ XCTAssertEqual ( body, " testCustomRoute2 test fixture \n " )
174
+ }
175
+ self . waitForExpectations ( timeout: timeout, handler: nil )
176
+ }
177
+
139
178
func testCustomRouteWithoutQueryParameters( ) {
140
179
let route : MockHTTPRoute = . custom(
141
180
method: . get,
0 commit comments