Skip to content

Commit

Permalink
Merge pull request #20 from kinkofer/Fix/Pokedex
Browse files Browse the repository at this point in the history
fix: Fix Pokedex endpoints
  • Loading branch information
kinkofer authored Jun 7, 2022
2 parents 37a011d + 518d6d2 commit 8fdf0f6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,33 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/PokemonAPI-App-watch WatchKit App">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "59EC43A8271A4B0A00B57CFC"
BuildableName = "PokemonAPI-App-watch WatchKit App.app"
BlueprintName = "PokemonAPI-App-watch WatchKit App"
ReferencedContainer = "container:PokemonAPI-App.xcodeproj">
</BuildableReference>
</RemoteRunnable>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<RemoteRunnable
runnableDebuggingMode = "2"
BundleIdentifier = "com.apple.Carousel"
RemotePath = "/PokemonAPI-App-watch WatchKit App">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "59EC43A8271A4B0A00B57CFC"
BuildableName = "PokemonAPI-App-watch WatchKit App.app"
BlueprintName = "PokemonAPI-App-watch WatchKit App"
ReferencedContainer = "container:PokemonAPI-App.xcodeproj">
</BuildableReference>
</RemoteRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "59EC43A8271A4B0A00B57CFC"
BuildableName = "PokemonAPI-App-watch WatchKit App.app"
BlueprintName = "PokemonAPI-App-watch WatchKit App"
ReferencedContainer = "container:PokemonAPI-App.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
40 changes: 8 additions & 32 deletions PokemonAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1281,10 +1281,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand All @@ -1309,10 +1306,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Expand Down Expand Up @@ -1359,10 +1353,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -1385,10 +1376,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/watchOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -1410,10 +1398,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -1435,10 +1420,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/tvOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "$(SRCROOT)/Resources/tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand Down Expand Up @@ -1489,10 +1471,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "$(SRCROOT)/Resources/macOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -1516,10 +1495,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "$(SRCROOT)/Resources/macOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "74B038581D5678AE00F48B92"
BuildableName = "PokemonAPI OSXTests.xctest"
BuildableName = "PokemonAPI macOSTests.xctest"
BlueprintName = "PokemonAPI macOSTests"
ReferencedContainer = "container:PokemonAPI.xcodeproj">
</BuildableReference>
Expand Down
4 changes: 2 additions & 2 deletions PokemonAPI/WebServices/GameService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ extension GameService {
*/
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
public func fetchPokedex(_ pokedexID: Int) async throws -> PKMPokedex {
try await PKMPokedex.decode(from: call(endpoint: API.fetchGenerationByID(pokedexID)))
try await PKMPokedex.decode(from: call(endpoint: API.fetchPokedexByID(pokedexID)))
}


Expand All @@ -451,7 +451,7 @@ extension GameService {
*/
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
public func fetchPokedex(_ pokedexName: String) async throws -> PKMPokedex {
try await PKMPokedex.decode(from: call(endpoint: API.fetchGenerationByName(pokedexName)))
try await PKMPokedex.decode(from: call(endpoint: API.fetchPokedexByName(pokedexName)))
}


Expand Down
21 changes: 0 additions & 21 deletions Tests/PokemonAPITests/Network Mocking/MockedResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@ extension RequestMocking.MockedResponse {
self.loadingTime = loadingTime
customResponse = nil
}


// init(apiCall: APICall, baseURL: String, customResponse: URLResponse) throws {
// guard let url = try apiCall.createUrlRequest(baseURL: baseURL).url else { throw Error.failedMockCreation }
// self.url = url
// result = .success(Data())
// httpCode = 200
// headers = [String: String]()
// loadingTime = 0
// self.customResponse = customResponse
// }
//
//
// init(url: URL, result: Result<Data, Swift.Error>) {
// self.url = url
// self.result = result
// httpCode = 200
// headers = [String: String]()
// loadingTime = 0
// customResponse = nil
// }
}


Expand Down
2 changes: 1 addition & 1 deletion Tests/PokemonAPITests/PokemonAPI_IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PokemonAPITests: XCTestCase {
}


@available(iOS 15.0, *)
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *)
func testFetchBerryInfo() async throws {
let asyncExpectation = expectation(description: "Fetch berry")
let _ = try await PokemonAPI().berryService.fetchBerry(1)
Expand Down
9 changes: 9 additions & 0 deletions Tests/PokemonAPITests/ServiceTests/ContestServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class ContestServiceTests: XCTestCase {

// MARK: - Tests

func testFetchContestTypeList_createUrl_success() async throws {
let paginationState: PaginationState<PKMContestType> = .initial(pageLimit: 5)
let url = try XCTUnwrap(API.fetchContestTypeList.createUrl(baseURL: service.baseURL, paginationState: paginationState), "The url should be created")

let targetUrl = URL(string: "https://pokeapi.co/api/v2/contest-type?limit=5&offset=0")!
XCTAssertTrue(targetUrl.compareComponents(url))
}


func testFetchContestTypeList_success() async throws {
let paginationState: PaginationState<PKMContestType> = .initial(pageLimit: 5)
try mock(.fetchContestTypeList, paginationState: paginationState, result: .success(MockContestData.contestTypeList))
Expand Down

0 comments on commit 8fdf0f6

Please sign in to comment.