-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
643 additions
and
169 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"configurations" : [ | ||
{ | ||
"id" : "B451EF4F-252F-4B7B-989D-F08BEE407A4A", | ||
"name" : "Test Scheme Action", | ||
"options" : { | ||
|
||
} | ||
} | ||
], | ||
"defaultOptions" : { | ||
"targetForVariableExpansion" : { | ||
"containerPath" : "container:LionHeart-iOS.xcodeproj", | ||
"identifier" : "B532E82D2A5525C600F0DB19", | ||
"name" : "LionHeart-iOS" | ||
} | ||
}, | ||
"testTargets" : [ | ||
{ | ||
"target" : { | ||
"containerPath" : "container:LionHeart-iOS.xcodeproj", | ||
"identifier" : "B532E8432A5525C800F0DB19", | ||
"name" : "LionHeart-iOSTests" | ||
} | ||
}, | ||
{ | ||
"enabled" : false, | ||
"parallelizable" : true, | ||
"target" : { | ||
"containerPath" : "container:LionHeart-iOS.xcodeproj", | ||
"identifier" : "B532E84D2A5525C800F0DB19", | ||
"name" : "LionHeart-iOSUITests" | ||
} | ||
} | ||
], | ||
"version" : 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Client.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"code": "N004", | ||
"message": "클라이언트에러" | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeFailure_Server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"code": "I001", | ||
"message": "서버에러가발생했습니다" | ||
} |
14 changes: 14 additions & 0 deletions
14
LionHeart-iOS/LionHeart-iOSTests/Challenge/ChallengeJSON/ChallengeSuccess.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"code": "SUCCESS", | ||
"message": "정보조회에성공했습니다", | ||
"data": { | ||
"babyNickname": "Test닉네임", | ||
"day": 10, | ||
"level": "LEVEL_ONE", | ||
"attendances": [ | ||
"11/1", | ||
"11/2", | ||
"11/3" | ||
] | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ChallengeServiceTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// ChallengeServiceTests.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by 김의성 on 12/01/23. | ||
// | ||
|
||
import XCTest | ||
@testable import LionHeart_iOS | ||
|
||
final class ChallengeServiceTests: XCTestCase { | ||
|
||
var apiService: Requestable! | ||
var urlSession: URLSessionStub! | ||
var jsonLoader: JSONLoader! | ||
var url: URL! | ||
|
||
override func setUpWithError() throws { | ||
self.jsonLoader = JSONLoader() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
self.jsonLoader = nil | ||
self.url = nil | ||
} | ||
|
||
func test_챌린지API_호출을_성공했을때() async throws { | ||
//given | ||
let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeSuccess") | ||
|
||
//when | ||
let returnData: ChallengeDataResponse? = try await self.apiService.request(urlRequest) | ||
let result = try XCTUnwrap(returnData, "언래핑실패") | ||
|
||
//then | ||
let expectation = ChallengeDataResponse(babyNickname: "Test닉네임", day: 10, level: "LEVEL_ONE", attendances: ["11/1","11/2","11/3"]) | ||
XCTAssertEqual(result.babyNickname, expectation.babyNickname) | ||
XCTAssertEqual(result.day, expectation.day) | ||
XCTAssertEqual(result.attendances, expectation.attendances) | ||
} | ||
|
||
func test_챌린지API_호출했을때_서버에러가발생한경우() async throws { | ||
//given | ||
let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeFailure_Server") | ||
|
||
//when | ||
var willOccureError: NetworkError? | ||
do { | ||
let _: ChallengeDataResponse? = try await self.apiService.request(urlRequest) | ||
XCTFail("성공할수없는 case입니다") | ||
} catch { | ||
let error = error as? NetworkError | ||
willOccureError = error | ||
} | ||
|
||
//then | ||
let expectation = NetworkError.serverError | ||
XCTAssertEqual(willOccureError, expectation) | ||
} | ||
|
||
func test_챌린지API_호출했을때_존재하지않는_챌린지인경우() async throws { | ||
//given | ||
let urlRequest = try self.setChallengeAPITest(fileName: "ChallengeFailure_Client") | ||
|
||
//when | ||
var willOccureError: NetworkError? | ||
do { | ||
let _: ChallengeDataResponse? = try await self.apiService.request(urlRequest) | ||
XCTFail("성공할수없는 case입니다") | ||
} catch { | ||
let error = error as? NetworkError | ||
willOccureError = error | ||
} | ||
|
||
//then | ||
let expectation = NetworkError.clientError(code: "N004", message: "클라이언트에러") | ||
XCTAssertEqual(willOccureError, expectation) | ||
} | ||
} | ||
|
||
private extension ChallengeServiceTests { | ||
func setChallengeAPITest(fileName: String) throws -> URLRequest { | ||
self.url = jsonLoader.load(fileName: fileName) | ||
let data = try Data(contentsOf: self.url) | ||
let urlRequest = URLRequest(url: self.url) | ||
self.urlSession = URLSessionStub(data: data) | ||
self.apiService = APIService(session: urlSession) | ||
return urlRequest | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
LionHeart-iOS/LionHeart-iOSTests/Challenge/ServiceTests/ServiceTests.swift
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeManagerStub.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// ChallengeManagerStub.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by uiskim on 2023/12/01. | ||
// | ||
|
||
import Foundation | ||
@testable import LionHeart_iOS | ||
|
||
final class ChallengeManagerStub: ChallengeManager { | ||
var returnValue: ChallengeDataResponse? | ||
|
||
func inquireChallengeInfo() async throws -> LionHeart_iOS.ChallengeData { | ||
guard let returnValue else { throw NetworkError.badCasting } | ||
return returnValue.toAppData() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
LionHeart-iOS/LionHeart-iOSTests/Challenge/Stubs/ChallengeNavigationDummy.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ChallengeNavigationStub.swift | ||
// LionHeart-iOSTests | ||
// | ||
// Created by uiskim on 2023/12/01. | ||
// | ||
|
||
import Foundation | ||
@testable import LionHeart_iOS | ||
|
||
final class ChallengeNavigationDummy: ChallengeNavigation { | ||
|
||
func navigationRightButtonTapped() { | ||
print("왼쪽버튼눌림") | ||
} | ||
|
||
func navigationLeftButtonTapped() { | ||
print("오른쪽버튼눌림") | ||
} | ||
|
||
func checkTokenIsExpired() { | ||
print("앱강제종료") | ||
} | ||
} |
Oops, something went wrong.