Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 586cfa6

Browse files
authored
Add tests for mime_type setting behavior in media lib count API (#621)
2 parents 275b80b + 8e16282 commit 586cfa6

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

WordPressKit.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,7 @@
39963996
repositoryURL = "https://github.com/buildkite/test-collector-swift";
39973997
requirement = {
39983998
kind = upToNextMajorVersion;
3999-
minimumVersion = 0.3.0;
3999+
minimumVersion = 0.4.0;
40004000
};
40014001
};
40024002
/* End XCRemoteSwiftPackageReference section */

WordPressKit.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WordPressKitTests/MediaServiceRemoteRESTTests.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)