@@ -2,11 +2,27 @@ import XCTest
22@testable import ATProtoKit
33
44final class ATProtoKitTests : XCTestCase {
5- func testExample ( ) throws {
6- // XCTest Documentation
7- // https://developer.apple. com/documentation/xctest
5+ func testSetQueryItemsPercentEncodesPlusSigns ( ) throws {
6+ let apiClientService = APIClientService ( with : APIClientConfiguration ( ) )
7+ let requestURL = try XCTUnwrap ( URL ( string : " https://example. com/xrpc/app.bsky.feed.getFeed " ) )
88
9- // Defining Test Cases and Test Methods
10- // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
9+ let urlWithPlus = try apiClientService. setQueryItems ( for: requestURL, with: [
10+ ( " cursor " , " abc+def " )
11+ ] )
12+ XCTAssertEqual ( urlWithPlus. absoluteString, " https://example.com/xrpc/app.bsky.feed.getFeed?cursor=abc%2Bdef " )
13+ XCTAssertFalse ( urlWithPlus. absoluteString. contains ( " + " ) )
14+
15+ let urlWithoutPlus = try apiClientService. setQueryItems ( for: requestURL, with: [
16+ ( " cursor " , " abcdef " )
17+ ] )
18+ XCTAssertEqual ( urlWithoutPlus. absoluteString, " https://example.com/xrpc/app.bsky.feed.getFeed?cursor=abcdef " )
19+ XCTAssertFalse ( urlWithoutPlus. absoluteString. contains ( " + " ) )
20+
21+ let urlWithMultipleItems = try apiClientService. setQueryItems ( for: requestURL, with: [
22+ ( " cursor " , " abc+def " ) ,
23+ ( " limit " , " 50 " )
24+ ] )
25+ XCTAssertEqual ( urlWithMultipleItems. absoluteString, " https://example.com/xrpc/app.bsky.feed.getFeed?cursor=abc%2Bdef&limit=50 " )
26+ XCTAssertFalse ( urlWithMultipleItems. absoluteString. contains ( " + " ) )
1127 }
1228}
0 commit comments