@@ -214,16 +214,39 @@ class MediaServiceRemoteRESTTests: RemoteTestCase, RESTTestable {
214214 XCTAssertEqual ( mockRemoteApi. URLStringPassedIn, expectedPath, " Wrong path " )
215215 }
216216
217- func testGetMediaLibraryCount( ) {
218-
217+ func testGetMediaLibraryCountNoType( ) throws {
219218 let expectedCount = 3
220219 let response = [ " found " : expectedCount]
220+
221221 var remoteCount = 0
222222 mediaServiceRemote. getMediaLibraryCount ( forType: nil , withSuccess: { ( count) in
223223 remoteCount = count
224224 } , failure: nil )
225+ // Note: This needs to be called here, after triggerting the API request, or it won't take effect
226+ // The behavior seems odd and ought to be researched.
227+ mockRemoteApi. successBlockPassedIn ? ( response as AnyObject , HTTPURLResponse ( ) )
228+
229+ XCTAssertEqual ( remoteCount, expectedCount)
230+ let params = try XCTUnwrap ( mockRemoteApi. parametersPassedIn as? [ String : Any ] )
231+ XCTAssertNil ( params [ " mime_type " ] as? String )
232+ }
233+
234+ func testGetMediaLibraryCountWithType( ) throws {
235+ let expectedCount = 3
236+ let response = [ " found " : expectedCount]
237+
238+ var remoteCount = 0
239+ mediaServiceRemote. getMediaLibraryCount ( forType: " a_type " , withSuccess: { ( count) in
240+ remoteCount = count
241+ } , failure: nil )
242+ // Note: This needs to be called here, after triggerting the API request, or it won't take effect.
243+ // The behavior seems odd and ought to be researched.
225244 mockRemoteApi. successBlockPassedIn ? ( response as AnyObject , HTTPURLResponse ( ) )
245+
226246 XCTAssertEqual ( remoteCount, expectedCount)
247+ let params = try XCTUnwrap ( mockRemoteApi. parametersPassedIn as? [ String : Any ] )
248+ let type = try XCTUnwrap ( params [ " mime_type " ] as? String )
249+ XCTAssertEqual ( type, " a_type " )
227250 }
228251
229252 func testRemoteMediaJSONParsing( ) {
0 commit comments