From d9ebff20aea537d57d8baf970ac80a5fce5b8b03 Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 01:58:04 +0900 Subject: [PATCH 1/6] =?UTF-8?q?:white=5Fcheck=5Fmark:=20SettingInteractorT?= =?UTF-8?q?ests=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/Layover/Layover.xcodeproj/project.pbxproj | 28 +++++ .../Scenes/Setting/SettingWorker.swift | 8 +- .../Mocks/Workers/MockHomeWorker.swift | 3 +- .../Mocks/Workers/MockSettingWorker.swift | 18 +++ .../Setting/SettingInteractorTests.swift | 108 ++++++++++++++++++ .../Setting/SettingPresenterTests.swift | 62 ++++++++++ .../Setting/SettingViewControllerTests.swift | 84 ++++++++++++++ .../Scenes/Setting/SettingWorkerTests.swift | 50 ++++++++ 8 files changed, 352 insertions(+), 9 deletions(-) create mode 100644 iOS/Layover/LayoverTests/Mocks/Workers/MockSettingWorker.swift create mode 100644 iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift create mode 100644 iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift create mode 100644 iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift create mode 100644 iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift diff --git a/iOS/Layover/Layover.xcodeproj/project.pbxproj b/iOS/Layover/Layover.xcodeproj/project.pbxproj index 32f4a75..047c884 100644 --- a/iOS/Layover/Layover.xcodeproj/project.pbxproj +++ b/iOS/Layover/Layover.xcodeproj/project.pbxproj @@ -104,6 +104,11 @@ 19A1694D2B18327E00DB34C0 /* sample.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 19A1694C2B18327E00DB34C0 /* sample.jpeg */; }; 19AACFCA2B0F7C3B0088143E /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AACFC92B0F7C3B0088143E /* Response.swift */; }; 19AACFCC2B0F7D730088143E /* LoginDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AACFCB2B0F7D730088143E /* LoginDTO.swift */; }; + 19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */; }; + 19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */; }; + 19AE48192B28C2B700DD4612 /* SettingWorkerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */; }; + 19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */; }; + 19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */; }; 19C7AFCE2B02410F003B35F2 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */; }; 19C7AFD62B02584D003B35F2 /* KeychainStored.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFD52B02584D003B35F2 /* KeychainStored.swift */; }; 19E79AC02B0A85D0009EA9ED /* LoopingPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */; }; @@ -341,6 +346,11 @@ 19AACFC52B0F71DF0088143E /* Secrets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Secrets.xcconfig; sourceTree = ""; }; 19AACFC92B0F7C3B0088143E /* Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Response.swift; sourceTree = ""; }; 19AACFCB2B0F7D730088143E /* LoginDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginDTO.swift; sourceTree = ""; }; + 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingViewControllerTests.swift; sourceTree = ""; }; + 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingInteractorTests.swift; sourceTree = ""; }; + 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingWorkerTests.swift; sourceTree = ""; }; + 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingPresenterTests.swift; sourceTree = ""; }; + 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSettingWorker.swift; sourceTree = ""; }; 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = ""; }; 19C7AFD52B02584D003B35F2 /* KeychainStored.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainStored.swift; sourceTree = ""; }; 19E79ABF2B0A85D0009EA9ED /* LoopingPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopingPlayerView.swift; sourceTree = ""; }; @@ -583,6 +593,7 @@ 194C21C72B1DF09B00C62645 /* Scenes */ = { isa = PBXGroup; children = ( + 19AE48122B28C2A800DD4612 /* Setting */, 192513632B26F7BB001533FA /* TagPlayList */, 1925137B2B277CC4001533FA /* Profile */, 194C21BE2B1DEE5500C62645 /* Home */, @@ -605,6 +616,7 @@ 194C21CB2B1DF39200C62645 /* MockHomeWorker.swift */, 1925136C2B26F84E001533FA /* MockTagPlayListWorker.swift */, 192513842B27852C001533FA /* MockUserWorker.swift */, + 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */, ); path = Workers; sourceTree = ""; @@ -722,6 +734,17 @@ path = DTOs; sourceTree = ""; }; + 19AE48122B28C2A800DD4612 /* Setting */ = { + isa = PBXGroup; + children = ( + 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */, + 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */, + 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */, + 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */, + ); + path = Setting; + sourceTree = ""; + }; 19BB8A572B07BEE30070B922 /* UIComponents */ = { isa = PBXGroup; children = ( @@ -1477,12 +1500,17 @@ 1925136B2B26F7CE001533FA /* TagPlayListPresenterTests.swift in Sources */, 192513682B26F7CE001533FA /* TagPlayListViewControllerTests.swift in Sources */, 1925136A2B26F7CE001533FA /* TagPlayListWorkerTests.swift in Sources */, + 19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */, 192513A72B278BB3001533FA /* Seeds.swift in Sources */, 194C21C52B1DEE6B00C62645 /* HomeWorkerTests.swift in Sources */, + 19AE48192B28C2B700DD4612 /* SettingWorkerTests.swift in Sources */, + 19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */, 192513802B277CD7001533FA /* ProfileViewControllerTests.swift in Sources */, 194C21C62B1DEE6B00C62645 /* HomePresenterTests.swift in Sources */, 1925137A2B273D98001533FA /* StubAuthManager.swift in Sources */, 1925136D2B26F84E001533FA /* MockTagPlayListWorker.swift in Sources */, + 19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */, + 19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */, 194C21C32B1DEE6B00C62645 /* HomeViewControllerTests.swift in Sources */, 192513692B26F7CE001533FA /* TagPlayListInteractorTests.swift in Sources */, 194C21CC2B1DF39200C62645 /* MockHomeWorker.swift in Sources */, diff --git a/iOS/Layover/Layover/Scenes/Setting/SettingWorker.swift b/iOS/Layover/Layover/Scenes/Setting/SettingWorker.swift index 8f99528..29e01bf 100644 --- a/iOS/Layover/Layover/Scenes/Setting/SettingWorker.swift +++ b/iOS/Layover/Layover/Scenes/Setting/SettingWorker.swift @@ -18,13 +18,7 @@ protocol SettingWorkerProtocol { final class SettingWorker: SettingWorkerProtocol { - // MARK: - Properties - - private let provider: ProviderType - - init(provider: ProviderType = Provider()) { - self.provider = provider - } + // MARK: - Methods func versionNumber() -> String? { System.versionNumber() diff --git a/iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift b/iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift index cef1ae8..09f13b5 100644 --- a/iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift +++ b/iOS/Layover/LayoverTests/Mocks/Workers/MockHomeWorker.swift @@ -6,11 +6,10 @@ // Copyright © 2023 CodeBomber. All rights reserved. // +@testable import Layover import Foundation import OSLog -@testable import Layover - final class MockHomeWorker: HomeWorkerProtocol { // MARK: - Properties diff --git a/iOS/Layover/LayoverTests/Mocks/Workers/MockSettingWorker.swift b/iOS/Layover/LayoverTests/Mocks/Workers/MockSettingWorker.swift new file mode 100644 index 0000000..7ae9bfd --- /dev/null +++ b/iOS/Layover/LayoverTests/Mocks/Workers/MockSettingWorker.swift @@ -0,0 +1,18 @@ +// +// MockSettingWorker.swift +// LayoverTests +// +// Created by 김인환 on 12/13/23. +// Copyright © 2023 CodeBomber. All rights reserved. +// +@testable import Layover +import Foundation + +final class MockSettingWorker: SettingWorkerProtocol { + + // MARK: - Methods + + func versionNumber() -> String? { + "7.7.7" + } +} diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift new file mode 100644 index 0000000..7869983 --- /dev/null +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift @@ -0,0 +1,108 @@ +// +// SettingInteractorTests.swift +// Layover +// +// Created by 김인환 on 12/13/23. +// Copyright (c) 2023 CodeBomber. All rights reserved. +// +// This file was generated by the Clean Swift Xcode Templates so +// you can apply clean architecture to your iOS and Mac projects, +// see http://clean-swift.com +// + +@testable import Layover +import XCTest + +final class SettingInteractorTests: XCTestCase { + // MARK: Subject under test + + var sut: SettingInteractor! + + typealias Models = SettingModels + + // MARK: - Test lifecycle + + override func setUp() { + super.setUp() + setupSettingInteractor() + } + + override func tearDown() { + super.tearDown() + } + + // MARK: - Test setup + + func setupSettingInteractor() { + sut = SettingInteractor() + sut.userWorker = MockUserWorker() + sut.settingWorker = MockSettingWorker() + } + + // MARK: - Test doubles + + final class SettingPresentationLogicSpy: SettingPresentationLogic { + var presentTableViewCalled = false + var presentTableViewResponse: Models.ConfigureTableView.Response! + var presentUserLogoutConfirmedCalled = false + var presentUserWithdrawConfirmedCalled = false + + func presentTableView(with response: Models.ConfigureTableView.Response) { + presentTableViewCalled = true + presentTableViewResponse = response + } + + func presentUserLogoutConfirmed(with response: Models.Logout.Response) { + presentUserLogoutConfirmedCalled = true + } + + func presentUserWithdrawConfirmed(with response: Models.Withdraw.Response) { + presentUserWithdrawConfirmedCalled = true + } + + + } + + // MARK: - Tests + + func test_performTableViewConfigure를_실행하면_presenter의_presentTableView가_호출되고_versionNumber를_전달한다() { + // arrange + let spy = SettingPresentationLogicSpy() + sut.presenter = spy + let request = Models.ConfigureTableView.Request() + + // act + sut.performTableViewConfigure(request: request) + + // assert + XCTAssertTrue(spy.presentTableViewCalled, "performTableViewConfigure()를 실행해서 presentTableView()가 호출했다.") + XCTAssertTrue(spy.presentTableViewResponse.versionNumber == "7.7.7", "presentTableView()를 실행해서 올바른 versionNumber를 전달했다.") + } + + func test_performUserLogout를_실행하면_presenter의_presentUserLogoutConfirmed가_호출된다() { + // arrange + let spy = SettingPresentationLogicSpy() + sut.presenter = spy + let request = Models.Logout.Request() + + // act + sut.performUserLogout(request: request) + + // assert + XCTAssertTrue(spy.presentUserLogoutConfirmedCalled, "performUserLogout()를 실행해서 presenter의 presentUserLogoutConfirmed()가 호출되었다.") + } + + func test_performUserWithdraw를_실행하면_presenter의_presentUserWithdrawConfirmed가_호출된다() async throws { + // arrange + let spy = SettingPresentationLogicSpy() + sut.presenter = spy + let request = Models.Withdraw.Request() + + // act + sut.performUserWithdraw(request: request) + try await Task.sleep(nanoseconds: 3_000_000_000) + + // assert + XCTAssertTrue(spy.presentUserWithdrawConfirmedCalled, "performUserWithdraw()를 실행해서 presenter의 presentUserWithdrawConfirmed()가 호출되었다.") + } +} diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift new file mode 100644 index 0000000..b6dd6cd --- /dev/null +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift @@ -0,0 +1,62 @@ +//// +//// SettingPresenterTests.swift +//// Layover +//// +//// Created by 김인환 on 12/13/23. +//// Copyright (c) 2023 CodeBomber. All rights reserved. +//// +//// This file was generated by the Clean Swift Xcode Templates so +//// you can apply clean architecture to your iOS and Mac projects, +//// see http://clean-swift.com +//// +// +//@testable import Layover +//import XCTest +// +//class SettingPresenterTests: XCTestCase { +// // MARK: Subject under test +// +// var sut: SettingPresenter! +// +// // MARK: - Test lifecycle +// +// override func setUp() { +// super.setUp() +// setupSettingPresenter() +// } +// +// override func tearDown() { +// super.tearDown() +// } +// +// // MARK: - Test setup +// +// func setupSettingPresenter() { +// sut = SettingPresenter() +// } +// +// // MARK: - Test doubles +// +// class SettingDisplayLogicSpy: SettingDisplayLogic { +// var displaySomethingCalled = false +// +// func displaySomething(viewModel: Setting.Something.ViewModel) { +// displaySomethingCalled = true +// } +// } +// +// // MARK: - Tests +// +// func testPresentSomething() { +// // Given +// let spy = SettingDisplayLogicSpy() +// sut.viewController = spy +// let response = Setting.Something.Response() +// +// // When +// sut.presentSomething(response: response) +// +// // Then +// XCTAssertTrue(spy.displaySomethingCalled, "presentSomething(response:) should ask the view controller to display the result") +// } +//} diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift new file mode 100644 index 0000000..9ab904b --- /dev/null +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift @@ -0,0 +1,84 @@ +//// +//// SettingViewControllerTests.swift +//// Layover +//// +//// Created by 김인환 on 12/13/23. +//// Copyright (c) 2023 CodeBomber. All rights reserved. +//// +//// This file was generated by the Clean Swift Xcode Templates so +//// you can apply clean architecture to your iOS and Mac projects, +//// see http://clean-swift.com +//// +// +//@testable import Layover +//import XCTest +// +//class SettingViewControllerTests: XCTestCase { +// // MARK: Subject under test +// +// var sut: SettingViewController! +// var window: UIWindow! +// +// // MARK: - Test lifecycle +// +// override func setUp() { +// super.setUp() +// window = UIWindow() +// setupSettingViewController() +// } +// +// override func tearDown() { +// window = nil +// super.tearDown() +// } +// +// // MARK: - Test setup +// +// func setupSettingViewController() { +// let bundle = Bundle.main +// let storyboard = UIStoryboard(name: "Main", bundle: bundle) +// sut = storyboard.instantiateViewController(withIdentifier: "SettingViewController") as! SettingViewController +// } +// +// func loadView() { +// window.addSubview(sut.view) +// RunLoop.current.run(until: Date()) +// } +// +// // MARK: - Test doubles +// +// class SettingBusinessLogicSpy: SettingBusinessLogic { +// var doSomethingCalled = false +// +// func doSomething(request: Setting.Something.Request) +// { +// doSomethingCalled = true +// } +// } +// +// // MARK: - Tests +// +// func testShouldDoSomethingWhenViewIsLoaded() { +// // Given +// let spy = SettingBusinessLogicSpy() +// sut.interactor = spy +// +// // When +// loadView() +// +// // Then +// XCTAssertTrue(spy.doSomethingCalled, "viewDidLoad() should ask the interactor to do something") +// } +// +// func testDisplaySomething() { +// // Given +// let viewModel = Setting.Something.ViewModel() +// +// // When +// loadView() +// sut.displaySomething(viewModel: viewModel) +// +// // Then +// //XCTAssertEqual(sut.nameTextField.text, "", "displaySomething(viewModel:) should update the name text field") +// } +//} diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift new file mode 100644 index 0000000..1be8d16 --- /dev/null +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift @@ -0,0 +1,50 @@ +//// +//// SettingWorkerTests.swift +//// Layover +//// +//// Created by 김인환 on 12/13/23. +//// Copyright (c) 2023 CodeBomber. All rights reserved. +//// +//// This file was generated by the Clean Swift Xcode Templates so +//// you can apply clean architecture to your iOS and Mac projects, +//// see http://clean-swift.com +//// +// +//@testable import Layover +//import XCTest +// +//class SettingWorkerTests: XCTestCase +//{ +// // MARK: Subject under test +// +// var sut: SettingWorker! +// +// // MARK: - Test lifecycle +// +// override func setUp() { +// super.setUp() +// setupSettingWorker() +// } +// +// override func tearDown() { +// super.tearDown() +// } +// +// // MARK: - Test setup +// +// func setupSettingWorker() { +// sut = SettingWorker() +// } +// +// // MARK: - Test doubles +// +// // MARK: - Tests +// +// func testSomething() { +// // Given +// +// // When +// +// // Then +// } +//} From a8d1ac8733db317763576be4e5acd286cba54650 Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 03:00:54 +0900 Subject: [PATCH 2/6] =?UTF-8?q?:white=5Fcheck=5Fmark:=20SettingPresenterTe?= =?UTF-8?q?sts=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iOS/Layover/Layover.xcodeproj/project.pbxproj | 4 - .../Setting/SettingInteractorTests.swift | 12 +- .../Setting/SettingPresenterTests.swift | 170 ++++++++++++------ .../Scenes/Setting/SettingWorkerTests.swift | 50 ------ 4 files changed, 116 insertions(+), 120 deletions(-) delete mode 100644 iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift diff --git a/iOS/Layover/Layover.xcodeproj/project.pbxproj b/iOS/Layover/Layover.xcodeproj/project.pbxproj index 047c884..2010426 100644 --- a/iOS/Layover/Layover.xcodeproj/project.pbxproj +++ b/iOS/Layover/Layover.xcodeproj/project.pbxproj @@ -106,7 +106,6 @@ 19AACFCC2B0F7D730088143E /* LoginDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AACFCB2B0F7D730088143E /* LoginDTO.swift */; }; 19AE48172B28C2B700DD4612 /* SettingViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */; }; 19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */; }; - 19AE48192B28C2B700DD4612 /* SettingWorkerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */; }; 19AE481A2B28C2B700DD4612 /* SettingPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */; }; 19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */; }; 19C7AFCE2B02410F003B35F2 /* AuthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */; }; @@ -348,7 +347,6 @@ 19AACFCB2B0F7D730088143E /* LoginDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginDTO.swift; sourceTree = ""; }; 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingViewControllerTests.swift; sourceTree = ""; }; 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingInteractorTests.swift; sourceTree = ""; }; - 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingWorkerTests.swift; sourceTree = ""; }; 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingPresenterTests.swift; sourceTree = ""; }; 19AE481B2B28C53800DD4612 /* MockSettingWorker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockSettingWorker.swift; sourceTree = ""; }; 19C7AFCD2B02410F003B35F2 /* AuthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthManager.swift; sourceTree = ""; }; @@ -739,7 +737,6 @@ children = ( 19AE48132B28C2B700DD4612 /* SettingViewControllerTests.swift */, 19AE48142B28C2B700DD4612 /* SettingInteractorTests.swift */, - 19AE48152B28C2B700DD4612 /* SettingWorkerTests.swift */, 19AE48162B28C2B700DD4612 /* SettingPresenterTests.swift */, ); path = Setting; @@ -1503,7 +1500,6 @@ 19AE48182B28C2B700DD4612 /* SettingInteractorTests.swift in Sources */, 192513A72B278BB3001533FA /* Seeds.swift in Sources */, 194C21C52B1DEE6B00C62645 /* HomeWorkerTests.swift in Sources */, - 19AE48192B28C2B700DD4612 /* SettingWorkerTests.swift in Sources */, 19AE481C2B28C53800DD4612 /* MockSettingWorker.swift in Sources */, 192513802B277CD7001533FA /* ProfileViewControllerTests.swift in Sources */, 194C21C62B1DEE6B00C62645 /* HomePresenterTests.swift in Sources */, diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift index 7869983..94f9e04 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift @@ -27,10 +27,6 @@ final class SettingInteractorTests: XCTestCase { setupSettingInteractor() } - override func tearDown() { - super.tearDown() - } - // MARK: - Test setup func setupSettingInteractor() { @@ -75,8 +71,8 @@ final class SettingInteractorTests: XCTestCase { sut.performTableViewConfigure(request: request) // assert - XCTAssertTrue(spy.presentTableViewCalled, "performTableViewConfigure()를 실행해서 presentTableView()가 호출했다.") - XCTAssertTrue(spy.presentTableViewResponse.versionNumber == "7.7.7", "presentTableView()를 실행해서 올바른 versionNumber를 전달했다.") + XCTAssertTrue(spy.presentTableViewCalled, "performTableViewConfigure()를 실행해서 presentTableView()를 호출되지 못했다.") + XCTAssertTrue(spy.presentTableViewResponse.versionNumber == "7.7.7", "presentTableView()를 실행해서 올바른 versionNumber가 전달되지 못했다.") } func test_performUserLogout를_실행하면_presenter의_presentUserLogoutConfirmed가_호출된다() { @@ -89,7 +85,7 @@ final class SettingInteractorTests: XCTestCase { sut.performUserLogout(request: request) // assert - XCTAssertTrue(spy.presentUserLogoutConfirmedCalled, "performUserLogout()를 실행해서 presenter의 presentUserLogoutConfirmed()가 호출되었다.") + XCTAssertTrue(spy.presentUserLogoutConfirmedCalled, "performUserLogout()를 실행해서 presenter의 presentUserLogoutConfirmed()를 호출되지 못했다.") } func test_performUserWithdraw를_실행하면_presenter의_presentUserWithdrawConfirmed가_호출된다() async throws { @@ -103,6 +99,6 @@ final class SettingInteractorTests: XCTestCase { try await Task.sleep(nanoseconds: 3_000_000_000) // assert - XCTAssertTrue(spy.presentUserWithdrawConfirmedCalled, "performUserWithdraw()를 실행해서 presenter의 presentUserWithdrawConfirmed()가 호출되었다.") + XCTAssertTrue(spy.presentUserWithdrawConfirmedCalled, "performUserWithdraw()를 실행해서 presenter의 presentUserWithdrawConfirmed()가 호출되지 못했다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift index b6dd6cd..de38c71 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingPresenterTests.swift @@ -1,62 +1,116 @@ -//// -//// SettingPresenterTests.swift -//// Layover -//// -//// Created by 김인환 on 12/13/23. -//// Copyright (c) 2023 CodeBomber. All rights reserved. -//// -//// This file was generated by the Clean Swift Xcode Templates so -//// you can apply clean architecture to your iOS and Mac projects, -//// see http://clean-swift.com -//// // -//@testable import Layover -//import XCTest +// SettingPresenterTests.swift +// Layover // -//class SettingPresenterTests: XCTestCase { -// // MARK: Subject under test +// Created by 김인환 on 12/13/23. +// Copyright (c) 2023 CodeBomber. All rights reserved. // -// var sut: SettingPresenter! +// This file was generated by the Clean Swift Xcode Templates so +// you can apply clean architecture to your iOS and Mac projects, +// see http://clean-swift.com // -// // MARK: - Test lifecycle -// -// override func setUp() { -// super.setUp() -// setupSettingPresenter() -// } -// -// override func tearDown() { -// super.tearDown() -// } -// -// // MARK: - Test setup -// -// func setupSettingPresenter() { -// sut = SettingPresenter() -// } -// -// // MARK: - Test doubles -// -// class SettingDisplayLogicSpy: SettingDisplayLogic { -// var displaySomethingCalled = false -// -// func displaySomething(viewModel: Setting.Something.ViewModel) { -// displaySomethingCalled = true -// } -// } -// -// // MARK: - Tests -// -// func testPresentSomething() { -// // Given -// let spy = SettingDisplayLogicSpy() -// sut.viewController = spy -// let response = Setting.Something.Response() -// -// // When -// sut.presentSomething(response: response) -// -// // Then -// XCTAssertTrue(spy.displaySomethingCalled, "presentSomething(response:) should ask the view controller to display the result") -// } -//} + +@testable import Layover +import XCTest + +final class SettingPresenterTests: XCTestCase { + // MARK: Subject under test + + var sut: SettingPresenter! + + typealias Models = SettingModels + + // MARK: - Test lifecycle + + override func setUp() { + super.setUp() + setupSettingPresenter() + } + + // MARK: - Test setup + + func setupSettingPresenter() { + sut = SettingPresenter() + } + + // MARK: - Test doubles + + class SettingDisplayLogicSpy: SettingDisplayLogic { + var displayTableViewCalled = false + var displayTableViewViewModel: Models.ConfigureTableView.ViewModel! + var displayUserLogoutConfirmedCalled = false + var displayUserWithdrawConfirmedCalled = false + + func displayTableView(viewModel: Models.ConfigureTableView.ViewModel) { + displayTableViewCalled = true + displayTableViewViewModel = viewModel + } + + func displayUserLogoutConfirmed(viewModel: Models.Logout.ViewModel) { + displayUserLogoutConfirmedCalled = true + } + + func displayUserWithdrawConfirmed(viewModel: Models.Withdraw.ViewModel) { + displayUserWithdrawConfirmedCalled = true + } + } + + // MARK: - Tests + + // 좋은 테스트는 아니다... + func test_presentTableView를_호출하면_viewController의_displayTableView가_호출되고_versionNumber가_포함된_올바른_TableViewSections이_전달된다() { + // Given + let spy = SettingDisplayLogicSpy() + sut.viewController = spy + let response = Models.ConfigureTableView.Response(versionNumber: "7.7.7") + + let versionSectionItem = Models.SectionItem(title: .version, + secondaryText: "7.7.7") + let versionSection = Models.TableSection(sectionTitle: .system, items: [versionSectionItem]) + + let expectSections = [Models.policySection, + versionSection, + Models.signOutSection] + + // When + sut.presentTableView(with: response) + + // Then + XCTAssertTrue(spy.displayTableViewCalled, "presentTableView()를 실행해서 viewController의 displayTableView()가 호출되지 못했다") + XCTAssertEqual(spy.displayTableViewViewModel.tableViewSections.count, expectSections.count, "presentTableView()를 실행해서 viewController의 displayTableView()에 전달된 tableViewSections의 개수가 다르다") + for (sectionIndex, section) in expectSections.enumerated() { + XCTAssertEqual(spy.displayTableViewViewModel.tableViewSections[sectionIndex].sectionTitle, section.sectionTitle) + + for (itemIndex, item) in section.items.enumerated() { + XCTAssertEqual(spy.displayTableViewViewModel.tableViewSections[sectionIndex].items[itemIndex].title, item.title) + XCTAssertEqual(spy.displayTableViewViewModel.tableViewSections[sectionIndex].items[itemIndex].secondaryText, item.secondaryText) + } + } + } + + func test_presentUserLogoutConfirmed를_호출하면_viewController의_displayUserLogoutConfirmed가_호출된다() { + // arrange + let spy = SettingDisplayLogicSpy() + sut.viewController = spy + let response = Models.Logout.Response() + + // act + sut.presentUserLogoutConfirmed(with: response) + + // assert + XCTAssertTrue(spy.displayUserLogoutConfirmedCalled, "presentUserLogoutConfirmed()를 실행해서 viewController의 displayUserLogoutConfirmed()가 호출되지 못했다") + } + + func test_presentUserWithdrawConfirmed를_호출하면_viewController의_displayUserWithdrawConfirmed가_호출된다() { + // arrange + let spy = SettingDisplayLogicSpy() + sut.viewController = spy + let response = Models.Withdraw.Response() + + // act + sut.presentUserWithdrawConfirmed(with: response) + + // assert + XCTAssertTrue(spy.displayUserWithdrawConfirmedCalled, "presentUserWithdrawConfirmed()를 실행해서 viewController의 displayUserWithdrawConfirmed()가 호출되지 못했다") + } +} diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift deleted file mode 100644 index 1be8d16..0000000 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingWorkerTests.swift +++ /dev/null @@ -1,50 +0,0 @@ -//// -//// SettingWorkerTests.swift -//// Layover -//// -//// Created by 김인환 on 12/13/23. -//// Copyright (c) 2023 CodeBomber. All rights reserved. -//// -//// This file was generated by the Clean Swift Xcode Templates so -//// you can apply clean architecture to your iOS and Mac projects, -//// see http://clean-swift.com -//// -// -//@testable import Layover -//import XCTest -// -//class SettingWorkerTests: XCTestCase -//{ -// // MARK: Subject under test -// -// var sut: SettingWorker! -// -// // MARK: - Test lifecycle -// -// override func setUp() { -// super.setUp() -// setupSettingWorker() -// } -// -// override func tearDown() { -// super.tearDown() -// } -// -// // MARK: - Test setup -// -// func setupSettingWorker() { -// sut = SettingWorker() -// } -// -// // MARK: - Test doubles -// -// // MARK: - Tests -// -// func testSomething() { -// // Given -// -// // When -// -// // Then -// } -//} From c0bbbc1e2dc5cc811b30fed2b7823678f66aa38b Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 03:07:18 +0900 Subject: [PATCH 3/6] =?UTF-8?q?:white=5Fcheck=5Fmark:=20SettingViewControl?= =?UTF-8?q?lerTests=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Setting/SettingViewControllerTests.swift | 152 ++++++++---------- 1 file changed, 69 insertions(+), 83 deletions(-) diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift index 9ab904b..06f6fdb 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift @@ -1,84 +1,70 @@ -//// -//// SettingViewControllerTests.swift -//// Layover -//// -//// Created by 김인환 on 12/13/23. -//// Copyright (c) 2023 CodeBomber. All rights reserved. -//// -//// This file was generated by the Clean Swift Xcode Templates so -//// you can apply clean architecture to your iOS and Mac projects, -//// see http://clean-swift.com -//// // -//@testable import Layover -//import XCTest -// -//class SettingViewControllerTests: XCTestCase { -// // MARK: Subject under test -// -// var sut: SettingViewController! -// var window: UIWindow! -// -// // MARK: - Test lifecycle -// -// override func setUp() { -// super.setUp() -// window = UIWindow() -// setupSettingViewController() -// } -// -// override func tearDown() { -// window = nil -// super.tearDown() -// } -// -// // MARK: - Test setup -// -// func setupSettingViewController() { -// let bundle = Bundle.main -// let storyboard = UIStoryboard(name: "Main", bundle: bundle) -// sut = storyboard.instantiateViewController(withIdentifier: "SettingViewController") as! SettingViewController -// } -// -// func loadView() { -// window.addSubview(sut.view) -// RunLoop.current.run(until: Date()) -// } -// -// // MARK: - Test doubles -// -// class SettingBusinessLogicSpy: SettingBusinessLogic { -// var doSomethingCalled = false -// -// func doSomething(request: Setting.Something.Request) -// { -// doSomethingCalled = true -// } -// } -// -// // MARK: - Tests -// -// func testShouldDoSomethingWhenViewIsLoaded() { -// // Given -// let spy = SettingBusinessLogicSpy() -// sut.interactor = spy -// -// // When -// loadView() -// -// // Then -// XCTAssertTrue(spy.doSomethingCalled, "viewDidLoad() should ask the interactor to do something") -// } -// -// func testDisplaySomething() { -// // Given -// let viewModel = Setting.Something.ViewModel() -// -// // When -// loadView() -// sut.displaySomething(viewModel: viewModel) -// -// // Then -// //XCTAssertEqual(sut.nameTextField.text, "", "displaySomething(viewModel:) should update the name text field") -// } -//} +// SettingViewControllerTests.swift +// Layover +// +// Created by 김인환 on 12/13/23. +// Copyright (c) 2023 CodeBomber. All rights reserved. +// +// This file was generated by the Clean Swift Xcode Templates so +// you can apply clean architecture to your iOS and Mac projects, +// see http://clean-swift.com +// + +@testable import Layover +import XCTest + +final class SettingViewControllerTests: XCTestCase { + // MARK: Subject under test + + var sut: SettingViewController! + + // MARK: - Test lifecycle + + override func setUp() { + super.setUp() + setupSettingViewController() + } + + // MARK: - Test setup + + func setupSettingViewController() { + sut = SettingViewController() + } + + // MARK: - Test doubles + + final class SettingBusinessLogicSpy: SettingBusinessLogic { + var performTableViewConfigureCalled = false + var performUserLogoutCalled = false + var performUserWithdrawCalled = false + + func performTableViewConfigure(request: Layover.SettingModels.ConfigureTableView.Request) { + performTableViewConfigureCalled = true + } + + func performUserLogout(request: Layover.SettingModels.Logout.Request) { + performUserLogoutCalled = true + } + + func performUserWithdraw(request: Layover.SettingModels.Withdraw.Request) -> Task { + performUserWithdrawCalled = true + return Task { + true + } + } + } + + // MARK: - Tests + + func test_setUI가_호출되면_interactor의_performTableViewConfigure를_호출한다() { + // arrange + let spy = SettingBusinessLogicSpy() + sut.interactor = spy + + // act + sut.setUI() + + // assert + XCTAssertTrue(spy.performTableViewConfigureCalled, "setUI()가 호출되어 performTableViewConfigure() 가 호출되지 않았다") + } +} From 801fe2eaab5f408393e47230f2b97bdf9beb04a6 Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 03:20:37 +0900 Subject: [PATCH 4/6] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=A4=ED=8C=A8=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Home/HomeInteractorTests.swift | 38 +++++++++---------- .../Scenes/Home/HomePresenterTests.swift | 24 ++++++------ .../Scenes/Home/HomeViewControllerTests.swift | 4 +- .../Scenes/Home/HomeWorkerTests.swift | 26 ++++++------- .../Profile/ProfileInteractorTests.swift | 26 ++++++------- .../Profile/ProfilePresenterTests.swift | 24 ++++++------ .../Profile/ProfileViewControllerTests.swift | 6 +-- .../TagPlayListInteractorTests.swift | 30 +++++++-------- .../TagPlayListViewControllerTests.swift | 12 +++--- .../TagPlayList/TagPlayListWorkerTests.swift | 28 +++++++------- 10 files changed, 109 insertions(+), 109 deletions(-) diff --git a/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift index e564631..decdffa 100644 --- a/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift @@ -67,21 +67,21 @@ final class HomeInteractorTests: XCTestCase { _ = await sut.fetchPosts(with: request).value // Assert - XCTAssertTrue(spy.presentPostsCalled, "fetchPost()가 presenter의 presentPosts()를 호출했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts.count, 1, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].tag, Seeds.Posts.post1.tag, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.identifier, Seeds.Posts.post1.board.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.title, Seeds.Posts.post1.board.title, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.description, Seeds.Posts.post1.board.description, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.latitude, Seeds.Posts.post1.board.latitude, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.longitude, Seeds.Posts.post1.board.longitude, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.videoURL, Seeds.Posts.post1.board.videoURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.username, Seeds.Posts.post1.member.username, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.introduce, Seeds.Posts.post1.member.introduce, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") - XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장했다.") + XCTAssertTrue(spy.presentPostsCalled, "fetchPost()가 presenter의 presentPosts()를 호출하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts.count, 1, "fetchPost()가 presenter에게 올바른 데이터 갯수를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].tag, Seeds.Posts.post1.tag, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.identifier, Seeds.Posts.post1.board.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.title, Seeds.Posts.post1.board.title, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.description, Seeds.Posts.post1.board.description, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.latitude, Seeds.Posts.post1.board.latitude, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.longitude, Seeds.Posts.post1.board.longitude, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].board.videoURL, Seeds.Posts.post1.board.videoURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.username, Seeds.Posts.post1.member.username, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.introduce, Seeds.Posts.post1.member.introduce, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") + XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") } func test_playPosts는_자신의_selectedIndex값을_변경한다() async throws { @@ -92,7 +92,7 @@ final class HomeInteractorTests: XCTestCase { sut.playPosts(with: request) // Assert - XCTAssertEqual(sut.postPlayStartIndex, 101, "playPosts()가 자신의 selectedIndex를 변경했다.") + XCTAssertEqual(sut.postPlayStartIndex, 101, "playPosts()가 자신의 selectedIndex를 변경하지 못했다.") } func test_playPosts는_presenter의_presentPlaybackScene를_호출한다() async throws { @@ -105,7 +105,7 @@ final class HomeInteractorTests: XCTestCase { sut.playPosts(with: request) // Assert - XCTAssertTrue(spy.presentPlaybackSceneCalled, "playPosts()가 presenter의 presentPlaybackScene()를 호출했다.") + XCTAssertTrue(spy.presentPlaybackSceneCalled, "playPosts()가 presenter의 presentPlaybackScene()를 호출하지 않았다.") } // TODO: - videoFileWorker Mock 객체 생성 후 테스트 코드 작성 @@ -138,7 +138,7 @@ final class HomeInteractorTests: XCTestCase { sut.showTagPlayList(with: request) // Assert - XCTAssertEqual(sut.selectedTag, "DummyTag", "showTagPlayList()가 자신의 selectedTag를 변경했다.") + XCTAssertEqual(sut.selectedTag, "DummyTag", "showTagPlayList()가 자신의 selectedTag를 변경되지 않았다.") } func test_showTagPlayList는_presenter의_presentTagPlayList를_호출한다() { @@ -151,6 +151,6 @@ final class HomeInteractorTests: XCTestCase { sut.showTagPlayList(with: request) // Assert - XCTAssertTrue(spy.presentTagPlayListCalled, "showTagPlayList()가 presenter의 presentTagPlayList()를 호출했다.") + XCTAssertTrue(spy.presentTagPlayListCalled, "showTagPlayList()가 presenter의 presentTagPlayList()를 호출되지 않았다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Home/HomePresenterTests.swift b/iOS/Layover/LayoverTests/Scenes/Home/HomePresenterTests.swift index 5fdeb99..6560aa6 100644 --- a/iOS/Layover/LayoverTests/Scenes/Home/HomePresenterTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Home/HomePresenterTests.swift @@ -72,12 +72,12 @@ final class HomePresenterTests: XCTestCase { sut.presentPosts(with: response) // assert - XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.") - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 1, "presentPosts는 올바른 갯수의 데이터를 전달했다.") - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].tags, Seeds.Posts.post1.tag) - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].title, Seeds.Posts.post1.board.title) - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL) - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].videoURL, Seeds.Posts.post1.board.videoURL, "presentPosts는 올바른 데이터를 전달했다.") + XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 1, "presentPosts는 올바른 갯수의 데이터를 전달하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].tags, Seeds.Posts.post1.tag, "presentPosts는 올바른 데이터를 전달하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].title, Seeds.Posts.post1.board.title, "presentPosts는 올바른 데이터를 전달하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "presentPosts는 올바른 데이터를 전달하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts[0].videoURL, Seeds.Posts.post1.board.videoURL, "presentPosts는 올바른 데이터를 전달하지 못했다.") } func test_presentPosts는_데이터의_썸네일_이미지_URL이_nil인_경우_뷰에게_해당_데이터를_전달하지_않는다() { @@ -90,8 +90,8 @@ final class HomePresenterTests: XCTestCase { sut.presentPosts(with: response) // assert - XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.") - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "썸네일 이미지 URL이 nil인 데이터는 뷰에게 전달하지 않는다.") + XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "썸네일 이미지 URL이 nil인 데이터가 뷰에게 전달되었다.") } func test_presentPosts는_데이터의_비디오_URL이_nil인_경우_뷰에게_해당_데이터를_전달하지_않는다() { @@ -104,8 +104,8 @@ final class HomePresenterTests: XCTestCase { sut.presentPosts(with: response) // assert - XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행했다.") - XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "비디오 URL이 nil인 데이터는 뷰에게 전달하지 않는다.") + XCTAssertTrue(spy.displayPostsCalled, "presentPosts는 displayPosts를 실행하지 못했다.") + XCTAssertEqual(spy.displayPostsReceivedViewModel.displayedPosts.count, 0, "비디오 URL이 nil인 데이터가 뷰에게 전달되었다.") } func test_presentPlaybackScene은_뷰의_routeToPlayback을_실행한다() { @@ -117,7 +117,7 @@ final class HomePresenterTests: XCTestCase { sut.presentPlaybackScene(with: Models.PlayPosts.Response()) // assert - XCTAssertTrue(spy.routeToPlaybackCalled, "presentPlaybackScene은 routeToPlayback을 실행했다.") + XCTAssertTrue(spy.routeToPlaybackCalled, "presentPlaybackScene은 routeToPlayback을 실행하지 못했다.") } func test_presentTagPlayList는_뷰의_routeToTagPlayList를_실행한다() { @@ -129,7 +129,7 @@ final class HomePresenterTests: XCTestCase { sut.presentTagPlayList(with: Models.ShowTagPlayList.Response()) // assert - XCTAssertTrue(spy.routeToTagPlayListCalled, "presentTagPlayListScene은 routeToTagPlayList를 실행했다.") + XCTAssertTrue(spy.routeToTagPlayListCalled, "presentTagPlayListScene은 routeToTagPlayList를 실행하지 못했다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Home/HomeViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Home/HomeViewControllerTests.swift index 9fc459c..8a82b71 100644 --- a/iOS/Layover/LayoverTests/Scenes/Home/HomeViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Home/HomeViewControllerTests.swift @@ -105,7 +105,7 @@ final class HomeViewControllerTests: XCTestCase { sut.routeToPlayback() // assert - XCTAssertTrue(spy.routeToPlaybackCalled, "routeToPlayback 호출 시 router의 routeToPlayback이 호출되었다.") + XCTAssertTrue(spy.routeToPlaybackCalled, "routeToPlayback 호출 시 router의 routeToPlayback이 호출되지 않았다.") } func test_routeToTagPlayList_호출시_router의_routeToTagPlay를_호출한다() { @@ -117,6 +117,6 @@ final class HomeViewControllerTests: XCTestCase { sut.routeToTagPlayList() // assert - XCTAssertTrue(spy.routeToTagPlayCalled, "routeToTagPlayList 호출 시 router의 routeToTagPlay가 호출되었다.") + XCTAssertTrue(spy.routeToTagPlayCalled, "routeToTagPlayList 호출 시 router의 routeToTagPlay가 호출되지 않았다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Home/HomeWorkerTests.swift b/iOS/Layover/LayoverTests/Scenes/Home/HomeWorkerTests.swift index 356a310..fa220f3 100644 --- a/iOS/Layover/LayoverTests/Scenes/Home/HomeWorkerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Home/HomeWorkerTests.swift @@ -59,19 +59,19 @@ final class HomeWorkerTests: XCTestCase { // assert XCTAssertNotNil(result) - XCTAssertEqual(result?.count, 1) - XCTAssertEqual(result![0].tag, Seeds.Posts.post1.tag) - XCTAssertEqual(result![0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL) - XCTAssertEqual(result![0].board.identifier, Seeds.Posts.post1.board.identifier) - XCTAssertEqual(result![0].board.title, Seeds.Posts.post1.board.title) - XCTAssertEqual(result![0].board.description, Seeds.Posts.post1.board.description) - XCTAssertEqual(result![0].board.videoURL, Seeds.Posts.post1.board.videoURL) - XCTAssertEqual(result![0].board.latitude, Seeds.Posts.post1.board.latitude) - XCTAssertEqual(result![0].board.longitude, Seeds.Posts.post1.board.longitude) - XCTAssertEqual(result![0].member.identifier, Seeds.Posts.post1.member.identifier) - XCTAssertEqual(result![0].member.username, Seeds.Posts.post1.member.username) - XCTAssertEqual(result![0].member.introduce, Seeds.Posts.post1.member.introduce) - XCTAssertEqual(result![0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost는_성공적으로_데이터를_받아오면_Post배열을_리턴한다.") + XCTAssertEqual(result?.count, 1, "fetchPost가 성공적으로 데이터를 받아와서 올바른 데이터 갯수를 리턴하지 못했다.") + XCTAssertEqual(result![0].tag, Seeds.Posts.post1.tag, "fetchPost가 성공적으로 데이터를 받아와서 올바른 tag를 리턴하지 못했다.") + XCTAssertEqual(result![0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.identifier, Seeds.Posts.post1.board.identifier, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.title, Seeds.Posts.post1.board.title, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.description, Seeds.Posts.post1.board.description, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.videoURL, Seeds.Posts.post1.board.videoURL, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.latitude, Seeds.Posts.post1.board.latitude, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].board.longitude, Seeds.Posts.post1.board.longitude, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].member.username, Seeds.Posts.post1.member.username, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].member.introduce, Seeds.Posts.post1.member.introduce, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") + XCTAssertEqual(result![0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPost가 성공적으로 데이터를_받아와서 Post배열을 리턴하지 못했다.") } func test_fetchPost는_데이터를_받아오지_못하면_nil을_리턴한다() async { diff --git a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift index 1efa357..b61dff9 100644 --- a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift @@ -75,13 +75,13 @@ final class ProfileInteractorTests: XCTestCase { _ = await sut.fetchProfile(with: Models.FetchProfile.Request()).value // assert - XCTAssertTrue(presentationLogicSpy.presentProfileCalled, "fetchProfile을 호출해서 presentProfile을 호출했다") - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts.count, 1) - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts[0].id, Seeds.Posts.post1.board.identifier) - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts[0].thumbnailImageData, Seeds.sampleImageData) - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.username, Seeds.Members.getMember1.username) - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.introduce, Seeds.Members.getMember1.introduce) - XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.profileImageData, Seeds.sampleImageData, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담겼다.") + XCTAssertTrue(presentationLogicSpy.presentProfileCalled, "fetchProfile을 호출해서 presentProfile을 호출하지 못했다") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts.count, 1, "presentProfileResponse에는 fetchProfile의 결과 갯수가 올바르게 담기지 못했다.") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts[0].id, Seeds.Posts.post1.board.identifier, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담기지 못했다.") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담기지 못했다.") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.username, Seeds.Members.getMember1.username, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담기지 못했다.") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.introduce, Seeds.Members.getMember1.introduce, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담기지 못했다.") + XCTAssertEqual(presentationLogicSpy.presentProfileResponse.userProfile.profileImageData, Seeds.sampleImageData, "presentProfileResponse에는 fetchProfile의 결과가 올바르게 담기지 못했다.") } func test_fetchMorePosts을_호출하면_presenter의_presentMorePosts을_호출하고_presentMorePostsResponse를_전달한다() async { @@ -93,10 +93,10 @@ final class ProfileInteractorTests: XCTestCase { _ = await sut.fetchMorePosts(with: Models.FetchMorePosts.Request()).value // assert - XCTAssertTrue(presentationLogicSpy.presentMorePostsCalled, "fetchMorePosts을 호출해서 presentMorePosts을 호출했다") - XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts.count, 1, "presentMorePostsResponse에는 fetchPosts의 결과가 담겼다") - XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts[0].id, Seeds.Posts.post1.board.identifier, "presentMorePostsResponse에는 fetchPosts의 결과가 담겼다") - XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "presentMorePostsResponse에는 fetchPosts의 결과가 담겼다") + XCTAssertTrue(presentationLogicSpy.presentMorePostsCalled, "fetchMorePosts을 호출해서 presentMorePosts을 호출하지 못했다") + XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts.count, 1, "presentMorePostsResponse에는 fetchPosts의 결과 갯수가 올바르게 담기지 못했다") + XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts[0].id, Seeds.Posts.post1.board.identifier, "presentMorePostsResponse에는 fetchPosts의 결과가 올바르게 담기지 못했다") + XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.posts[0].thumbnailImageData, Seeds.sampleImageData, "presentMorePostsResponse에는 fetchPosts의 결과가 올바르게 담기지 못했다") } func test_showPostDetail을_호출하면_자신의_playbackStartIndex에_값을_저장하고_presenter의_presentPostDetail을_호출한다() async { @@ -108,7 +108,7 @@ final class ProfileInteractorTests: XCTestCase { sut.showPostDetail(with: Models.ShowPostDetail.Request(startIndex: 7)) // assert - XCTAssertEqual(sut.playbackStartIndex, 7, "showPostDetail을 호출해서 playbackStartIndex에 값을 저장했다") - XCTAssertTrue(presentationLogicSpy.presentPostDetailCalled, "showPostDetail을 호출해서 presentPostDetail을 호출했다") + XCTAssertEqual(sut.playbackStartIndex, 7, "showPostDetail을 호출해서 playbackStartIndex에 값을 저장하지 못했다") + XCTAssertTrue(presentationLogicSpy.presentPostDetailCalled, "showPostDetail을 호출해서 presentPostDetail을 호출하지 못했다") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Profile/ProfilePresenterTests.swift b/iOS/Layover/LayoverTests/Scenes/Profile/ProfilePresenterTests.swift index fa71998..017f0cd 100644 --- a/iOS/Layover/LayoverTests/Scenes/Profile/ProfilePresenterTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Profile/ProfilePresenterTests.swift @@ -77,13 +77,13 @@ final class ProfilePresenterTests: XCTestCase { sut.presentProfile(with: response) // assert - XCTAssertTrue(spy.displayProfileDidCalled, "presentProfile은 displayProfile을 호출했다") - XCTAssertEqual(spy.displayProfileViewModel.userProfile.username, Seeds.Members.getMember1.username) - XCTAssertEqual(spy.displayProfileViewModel.userProfile.introduce, Seeds.Members.getMember1.introduce) - XCTAssertEqual(spy.displayProfileViewModel.userProfile.profileImageData, Seeds.sampleImageData) - XCTAssertEqual(spy.displayProfileViewModel.posts.count, 1) - XCTAssertEqual(spy.displayProfileViewModel.posts.first?.id, Seeds.Posts.post1.board.identifier) - XCTAssertEqual(spy.displayProfileViewModel.posts.first?.thumbnailImageData, Seeds.sampleImageData, "presentprofile은 올바른 데이터를 뷰에 전달했다") + XCTAssertTrue(spy.displayProfileDidCalled, "presentProfile은 displayProfile을 호출하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.userProfile.username, Seeds.Members.getMember1.username, "presentprofile은 올바른 데이터를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.userProfile.introduce, Seeds.Members.getMember1.introduce, "presentprofile은 올바른 데이터를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.userProfile.profileImageData, Seeds.sampleImageData, "presentprofile은 올바른 데이터를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.posts.count, 1, "presentprofile은 올바른 데이터 갯수를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.posts.first?.id, Seeds.Posts.post1.board.identifier, "presentprofile은 올바른 데이터를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayProfileViewModel.posts.first?.thumbnailImageData, Seeds.sampleImageData, "presentprofile은 올바른 데이터를 뷰에 전달하지 못했다") } func test_presentMorePosts을_호출하면_displayMorePosts를_호출하고_올바른_데이터를_전달한다() { @@ -97,10 +97,10 @@ final class ProfilePresenterTests: XCTestCase { sut.presentMorePosts(with: response) // assert - XCTAssertTrue(spy.displayMorePostsCalled, "presentMorePosts은 displayMorePosts을 호출했다") - XCTAssertEqual(spy.displayMorePostsViewModel.posts.count, 1) - XCTAssertEqual(spy.displayMorePostsViewModel.posts.first?.id, Seeds.Posts.post1.board.identifier) - XCTAssertEqual(spy.displayMorePostsViewModel.posts.first?.thumbnailImageData, Seeds.sampleImageData, "presentMorePosts은 올바른 데이터를 뷰에 전달했다") + XCTAssertTrue(spy.displayMorePostsCalled, "presentMorePosts은 displayMorePosts을 호출하지 못했다") + XCTAssertEqual(spy.displayMorePostsViewModel.posts.count, 1, "presentMorePosts은 올바른 데이터 갯수를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayMorePostsViewModel.posts.first?.id, Seeds.Posts.post1.board.identifier, "presentMorePosts은 올바른 데이터를 뷰에 전달하지 못했다") + XCTAssertEqual(spy.displayMorePostsViewModel.posts.first?.thumbnailImageData, Seeds.sampleImageData, "presentMorePosts은 올바른 데이터를 뷰에 전달하지 못했다") } func test_presentPostDetail을_호출하면_routeToPostDetail을_호출한다() { @@ -112,6 +112,6 @@ final class ProfilePresenterTests: XCTestCase { sut.presentPostDetail(with: .init()) // assert - XCTAssertTrue(spy.routeToPostDetailCalled, "presentPostDetail은 routeToPostDetail을 호출했다") + XCTAssertTrue(spy.routeToPostDetailCalled, "presentPostDetail은 routeToPostDetail을 호출하지 못했다") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift index 5cdb587..43ad147 100644 --- a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift @@ -72,7 +72,7 @@ final class ProfileViewControllerTests: XCTestCase { sut.viewWillAppear(false) // assert - XCTAssertTrue(spy.fetchProfileCalled, "viewWillAppear가 호출되어 fetchProfile이 호출했다") + XCTAssertTrue(spy.fetchProfileCalled, "viewWillAppear가 호출되어 fetchProfile를 호출하지 못했다") } func test_스크롤이_바닥에_닿아_scrollViewBeginDecelerating이_호출되면_fetchPosts가_호출된다() { @@ -88,7 +88,7 @@ final class ProfileViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // assert - XCTAssertTrue(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿아 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출했다") + XCTAssertTrue(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿아 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출하지 못했다") } func test_스크롤이_바닥에_닿지_않고_scrollViewBeginDecelerating이_호출되면_fetchPosts가_호출된다() { @@ -104,6 +104,6 @@ final class ProfileViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // assert - XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿지 않고 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출되지 않았다") + XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿지 않고 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출되었다") } } diff --git a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift index acf4c1e..30bb14d 100644 --- a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift @@ -87,8 +87,8 @@ final class TagPlayListInteractorTests: XCTestCase { sut.setTitleTag(request: request) // Assert - XCTAssertTrue(spy.presentTitleTagCalled, "setTitleTag()가 presenter의 presentTitleTag()를 호출했다.") - XCTAssertEqual(sut.titleTag, spy.presentTitleTagResponse.titleTag, "setTitleTag()가 presenter에게 자신의 titleTag를 전달했다.") + XCTAssertTrue(spy.presentTitleTagCalled, "setTitleTag()가 presenter의 presentTitleTag()를 호출하지 못했다.") + XCTAssertEqual(sut.titleTag, spy.presentTitleTagResponse.titleTag, "setTitleTag()가 presenter에게 자신의 titleTag를 전달하지 못했다.") } func test_fetchPlayList를_호출하면_자신의_posts에_데이터를_저장하고_presenter의_presentPlayList를_호출하여_올바른_데이터를_전달한다() async { @@ -115,11 +115,11 @@ final class TagPlayListInteractorTests: XCTestCase { XCTAssertEqual(sut.posts[0].member.identifier, Seeds.Posts.post1.member.identifier) XCTAssertEqual(sut.posts[0].member.username, Seeds.Posts.post1.member.username) XCTAssertEqual(sut.posts[0].member.introduce, Seeds.Posts.post1.member.introduce) - XCTAssertEqual(sut.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPlayList()가 자신의 posts에 올바른 posts 데이터를 저장했다.") + XCTAssertEqual(sut.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPlayList()가 자신의 posts에 올바른 posts 데이터를 저장하지 못했다.") XCTAssertEqual(spy.presentPlayListResponse.post.count, 1) XCTAssertEqual(spy.presentPlayListResponse.post[0].identifier, Seeds.Posts.post1.board.identifier) XCTAssertEqual(spy.presentPlayListResponse.post[0].thumbnailImageData, Seeds.sampleImageData) - XCTAssertEqual(spy.presentPlayListResponse.post[0].title, Seeds.Posts.post1.board.title, "fetchPlayList()가 presenter에게 올바른 displayedPosts 데이터를 전달했다.") + XCTAssertEqual(spy.presentPlayListResponse.post[0].title, Seeds.Posts.post1.board.title, "fetchPlayList()가 presenter에게 올바른 displayedPosts 데이터를 전달하지 못했다.") } func test_fetchPlayList를_호출하면_기존에_저장된_posts를_비우고_새로운_Posts_데이터를_저장한다() async { @@ -160,7 +160,7 @@ final class TagPlayListInteractorTests: XCTestCase { XCTAssertEqual(sut.posts[0].member.identifier, Seeds.Posts.post1.member.identifier) XCTAssertEqual(sut.posts[0].member.username, Seeds.Posts.post1.member.username) XCTAssertEqual(sut.posts[0].member.introduce, Seeds.Posts.post1.member.introduce) - XCTAssertEqual(sut.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPlayList()가 자신의 posts에 올바른 posts 데이터를 저장했다.") + XCTAssertEqual(sut.posts[0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "fetchPlayList()가 자신의 posts에 올바른 posts 데이터를 저장하지 못했다.") } func test_fetchMorePlayList를_호출하면_자신의_posts에_데이터를_저장하고_presenter의_presentMorePlayList를_호출하여_올바른_Posts_데이터를_전달한다() async { @@ -174,11 +174,11 @@ final class TagPlayListInteractorTests: XCTestCase { _ = await sut.fetchMorePlayList(request: fetchMoreRequest).value // Assert - XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출했다.") - XCTAssertEqual(spy.presentMorePlayListResponse.post.count, 1, "fetchPlayMoreList()가 presenter에게 올바른 갯수의 posts 데이터를 전달했다.") + XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") + XCTAssertEqual(spy.presentMorePlayListResponse.post.count, 1, "fetchPlayMoreList()가 presenter에게 올바른 갯수의 posts 데이터를 전달하지 못했다.") XCTAssertEqual(spy.presentMorePlayListResponse.post[0].identifier, Seeds.Posts.post1.board.identifier) XCTAssertEqual(spy.presentMorePlayListResponse.post[0].thumbnailImageData, Seeds.sampleImageData) - XCTAssertEqual(spy.presentMorePlayListResponse.post[0].title, Seeds.Posts.post1.board.title, "fetchPlayMoreList()가 presenter에게 올바른 displayedPosts 데이터를 전달했다.") + XCTAssertEqual(spy.presentMorePlayListResponse.post[0].title, Seeds.Posts.post1.board.title, "fetchPlayMoreList()가 presenter에게 올바른 displayedPosts 데이터를 전달하지 못했다.") } func test_fetchMorePlayList를_호출하다가_더이상_가져온_데이터가_없으면_본인의_post개수를_유지하고_presenter의_presentMorePlayList를_호출하여_빈_배열을_전달한다() async { @@ -193,9 +193,9 @@ final class TagPlayListInteractorTests: XCTestCase { _ = await sut.fetchMorePlayList(request: request).value // Assert - XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출했다.") - XCTAssertEqual(sut.posts.count, 2, "fetchPlayMoreList()를 호출하다가 더이상 데이터가 없을 때 자신의 posts를 유지했다.") - XCTAssertEqual(spy.presentMorePlayListResponse.post.count, 0, "fetchPlayMoreList()가 presenter에게 빈 배열을 전달했다.") + XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") + XCTAssertEqual(sut.posts.count, 2, "fetchPlayMoreList()를 호출하다가 더이상 데이터가 없을 때 자신의 posts를 유지하지 못했다.") + XCTAssertEqual(spy.presentMorePlayListResponse.post.count, 0, "fetchPlayMoreList()가 presenter에게 빈 배열을 전달하지 못했다.") } func test_fetchMorePlayList를_호출하면_기존_자신의_posts에_새로운_Posts_데이터가_추가되어_저장한다() async { @@ -210,7 +210,7 @@ final class TagPlayListInteractorTests: XCTestCase { _ = await sut.fetchMorePlayList(request: request).value // Assert - XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출했다.") + XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") XCTAssertEqual(sut.posts.filter({ $0.board.identifier == Seeds.Posts.post1.board.identifier && $0.board.title == Seeds.Posts.post1.board.title @@ -225,7 +225,7 @@ final class TagPlayListInteractorTests: XCTestCase { && $0.member.profileImageURL == Seeds.Posts.post1.member.profileImageURL && $0.tag == Seeds.Posts.post1.tag }).count, 2) - XCTAssertEqual(sut.posts.count, 2, "fetchPlayMoreList()가 자신의 posts에 새로운 posts 데이터를 더해서 저장했다.") + XCTAssertEqual(sut.posts.count, 2, "fetchPlayMoreList()가 자신의 posts에 새로운 posts 데이터를 더해서 저장하지 못했다.") } func test_showPostDetail을_호출하면_자신의_postPlayStartIndex값을_올바르게_저장하고_presenter의_presentPostDetail을_호출한다() { @@ -238,7 +238,7 @@ final class TagPlayListInteractorTests: XCTestCase { sut.showPostsDetail(request: request) // Assert - XCTAssertEqual(sut.postPlayStartIndex, 7, "showPostDetail()가 presenter에게 올바른 startIndex를 전달했다.") - XCTAssertTrue(spy.presentPostsDetailCalled, "showPostDetail()가 presenter의 presentPostDetail()를 호출했다.") + XCTAssertEqual(sut.postPlayStartIndex, 7, "showPostDetail()가 presenter에게 올바른 startIndex를 전달하지 못했다.") + XCTAssertTrue(spy.presentPostsDetailCalled, "showPostDetail()가 presenter의 presentPostDetail()를 호출하지 못했다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift index 078019d..5f27bdd 100644 --- a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift @@ -97,7 +97,7 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.viewDidLoad() // Assert - XCTAssertTrue(spy.setTitleTagCalled, "viewDidLoad() 가 호출되면 interactor에게 titleTag를 요청했다.") + XCTAssertTrue(spy.setTitleTagCalled, "viewDidLoad() 가 호출되어 interactor에게 titleTag를 요청하지 못했다.") } func test_viewWillAppear가_호출되면_interactor에게_playList를_요청한다() { @@ -109,7 +109,7 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.viewWillAppear(true) // Assert - XCTAssertTrue(spy.fetchPlayListCalled, "viewWillAppear() 가 호출되면 interactor의 fetchPlayList를 호출했다.") + XCTAssertTrue(spy.fetchPlayListCalled, "viewWillAppear()가 호출되어 interactor의 fetchPlayList를 호출하지 못했다.") } func test_scrollView가_아래_끝에_다다라_scrollViewWillBeginDecelearting가_호출되면_interactor의_fetchMorePlayList를_호출한다() { @@ -124,7 +124,7 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // Assert - XCTAssertTrue(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다라 scrollViewWillBeginDecelerating() 이 호출되면 interactor의 fetchMorePlayList를 호출했다.") + XCTAssertTrue(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다라 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출하지 못했다.") } func test_scrollView가_아래_끝에_다다르지_않은_상태에서_scrollViewWillBeginDecelearting가_호출되면_interactor의_fetchMorePlayList를_호출하지_않는다() { @@ -139,7 +139,7 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // Assert - XCTAssertFalse(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다르지 않고 scrollViewWillBeginDecelerating() 이 호출되면 interactor의 fetchMorePlayList를 호출하지 않는다.") + XCTAssertFalse(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다르지 않고 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출했다.") } func test_collectionView의_didSelectItemAt이_호출되면_interactor에게_showPostsDetail를_요청한다() { @@ -152,7 +152,7 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.collectionView(collectionView, didSelectItemAt: IndexPath(item: 0, section: 0)) // Assert - XCTAssertTrue(spy.showPostsDetailCalled, "collectionView의 didSelectItemAt이 호출되면 interactor에게 showPostsDetail를 요청했다.") + XCTAssertTrue(spy.showPostsDetailCalled, "collectionView의 didSelectItemAt을 호출해서 interactor에게 showPostsDetail를 요청하지 못했다.") } func test_collectionView의_didSelectItemAt이_호출되면_router에게_routeToPlayback을_요청한다() { @@ -165,6 +165,6 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.collectionView(collectionView, didSelectItemAt: IndexPath(item: 0, section: 0)) // Assert - XCTAssertTrue(spy.routeToPlaybackCalled, "collectionView의 didSelectItemAt이 호출되면 router에게 routeToPlayback을 요청했다.") + XCTAssertTrue(spy.routeToPlaybackCalled, "collectionView의 didSelectItemAt을 호출해서 router에게 routeToPlayback을 요청하지 못했다.") } } diff --git a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListWorkerTests.swift b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListWorkerTests.swift index 6c9de3f..ff224bd 100644 --- a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListWorkerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListWorkerTests.swift @@ -57,19 +57,19 @@ final class TagPlayListWorkerTests: XCTestCase { // assert XCTAssertNotNil(result) - XCTAssertEqual(result?.count, 1) - XCTAssertEqual(result![0].tag, Seeds.Posts.post1.tag) - XCTAssertEqual(result![0].board.title, Seeds.Posts.post1.board.title) - XCTAssertEqual(result![0].board.identifier, Seeds.Posts.post1.board.identifier) - XCTAssertEqual(result![0].board.description, Seeds.Posts.post1.board.description) - XCTAssertEqual(result![0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL) - XCTAssertEqual(result![0].board.videoURL, Seeds.Posts.post1.board.videoURL) - XCTAssertEqual(result![0].board.latitude, Seeds.Posts.post1.board.latitude) - XCTAssertEqual(result![0].board.longitude, Seeds.Posts.post1.board.longitude) - XCTAssertEqual(result![0].member.identifier, Seeds.Posts.post1.member.identifier) - XCTAssertEqual(result![0].member.username, Seeds.Posts.post1.member.username) - XCTAssertEqual(result![0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL) - XCTAssertEqual(result![0].member.introduce, Seeds.Posts.post1.member.introduce) + XCTAssertEqual(result?.count, 1, "올바른 갯수의 Post가 반환되지 않았다.") + XCTAssertEqual(result![0].tag, Seeds.Posts.post1.tag, "올바른 tag가 반환되지 않았다.") + XCTAssertEqual(result![0].board.title, Seeds.Posts.post1.board.title, "올바른 board title이 반환되지 않았다.") + XCTAssertEqual(result![0].board.identifier, Seeds.Posts.post1.board.identifier, "올바른 board identifier가 반환되지 않았다.") + XCTAssertEqual(result![0].board.description, Seeds.Posts.post1.board.description, "올바른 board description이 반환되지 않았다.") + XCTAssertEqual(result![0].board.thumbnailImageURL, Seeds.Posts.post1.board.thumbnailImageURL, "올바른 board thumbnailImageURL이 반환되지 않았다.") + XCTAssertEqual(result![0].board.videoURL, Seeds.Posts.post1.board.videoURL, "올바른 board videoURL이 반환되지 않았다.") + XCTAssertEqual(result![0].board.latitude, Seeds.Posts.post1.board.latitude, "올바른 board latitude가 반환되지 않았다.") + XCTAssertEqual(result![0].board.longitude, Seeds.Posts.post1.board.longitude, "올바른 board longitude가 반환되지 않았다.") + XCTAssertEqual(result![0].member.identifier, Seeds.Posts.post1.member.identifier, "올바른 member identifier가 반환되지 않았다.") + XCTAssertEqual(result![0].member.username, Seeds.Posts.post1.member.username, "올바른 member username이 반환되지 않았다.") + XCTAssertEqual(result![0].member.profileImageURL, Seeds.Posts.post1.member.profileImageURL, "올바른 member profileImageURL이 반환되지 않았다.") + XCTAssertEqual(result![0].member.introduce, Seeds.Posts.post1.member.introduce, "올바른 member introduce가 반환되지 않았다.") } func test_fetchPlayList를_호출했을때_404_에러가_발생하면_nil을_반환한다() async { @@ -88,7 +88,7 @@ final class TagPlayListWorkerTests: XCTestCase { result = await sut.fetchPlayList(of: "안유진", at: 1) // assert - XCTAssertNil(result) + XCTAssertNil(result, "nil이 반환되지 않았다.") } func test_loadImageData를_호출하면_이미지데이터를_반환한다() async { From 0ab016544f4e9a3f0824de98cdcea016122de76f Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 15:59:30 +0900 Subject: [PATCH 5/6] =?UTF-8?q?:wrench:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Setting/SettingViewControllerTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift index 06f6fdb..e8f3813 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift @@ -65,6 +65,6 @@ final class SettingViewControllerTests: XCTestCase { sut.setUI() // assert - XCTAssertTrue(spy.performTableViewConfigureCalled, "setUI()가 호출되어 performTableViewConfigure() 가 호출되지 않았다") + XCTAssertTrue(spy.performTableViewConfigureCalled, "setUI()가 호출됐지만 performTableViewConfigure()가 호출되지 않았다") } } From f7a742689ea7793243ea854aadc407ece7f70ab0 Mon Sep 17 00:00:00 2001 From: loinsir Date: Wed, 13 Dec 2023 19:32:36 +0900 Subject: [PATCH 6/6] =?UTF-8?q?:wrench:=20Task=20=EB=A6=AC=ED=84=B4=20?= =?UTF-8?q?=ED=98=95=EC=8B=9D=20=EC=82=AD=EC=A0=9C,=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditProfile/EditProfileInteractor.swift | 82 +++++++++---------- .../EditProfileViewController.swift | 8 +- .../Layover/Scenes/Home/HomeInteractor.swift | 20 ++--- .../Scenes/Home/HomeViewController.swift | 4 +- .../Scenes/Profile/ProfileInteractor.swift | 81 +++++++++--------- .../Profile/ProfileViewController.swift | 8 +- .../Scenes/Setting/SettingInteractor.swift | 16 ++-- .../Setting/SettingViewController.swift | 4 +- .../TagPlayList/TagPlayListInteractor.swift | 64 +++++++-------- .../TagPlayListViewController.swift | 8 +- .../Scenes/Home/HomeInteractorTests.swift | 6 +- .../Profile/ProfileInteractorTests.swift | 6 +- .../Profile/ProfileViewControllerTests.swift | 26 +++--- .../Setting/SettingInteractorTests.swift | 5 +- .../Setting/SettingViewControllerTests.swift | 6 +- .../TagPlayListInteractorTests.swift | 14 ++-- .../TagPlayListViewControllerTests.swift | 34 ++++---- 17 files changed, 198 insertions(+), 194 deletions(-) diff --git a/iOS/Layover/Layover/Scenes/EditProfile/EditProfileInteractor.swift b/iOS/Layover/Layover/Scenes/EditProfile/EditProfileInteractor.swift index fc5ff12..9343d1c 100644 --- a/iOS/Layover/Layover/Scenes/EditProfile/EditProfileInteractor.swift +++ b/iOS/Layover/Layover/Scenes/EditProfile/EditProfileInteractor.swift @@ -13,9 +13,9 @@ import OSLog protocol EditProfileBusinessLogic { func setProfile(with request: EditProfileModels.SetProfile.Request) func changeProfile(with request: EditProfileModels.ChangeProfile.Request) - func checkDuplication(with request: EditProfileModels.CheckNicknameDuplication.Request) + func checkDuplication(with request: EditProfileModels.CheckNicknameDuplication.Request) async -> Bool @discardableResult - func editProfile(with request: EditProfileModels.EditProfile.Request) -> Task + func editProfile(with request: EditProfileModels.EditProfile.Request) async -> Bool } protocol EditProfileDataStore { @@ -96,18 +96,17 @@ final class EditProfileInteractor: EditProfileBusinessLogic, EditProfileDataStor presenter?.presentProfileState(with: response) } - func checkDuplication(with request: Models.CheckNicknameDuplication.Request) { - Task { - guard let response = await userWorker?.checkNotDuplication(for: request.nickname) else { - os_log(.error, log: .data, "checkDuplication Server Error") - return - } - didCheckedNicknameDuplicate = response - let canEditProfile = didCheckedNicknameDuplicate && nicknameState == .valid && introduceState == .valid - await MainActor.run { - presenter?.presentNicknameDuplication(with: Models.CheckNicknameDuplication.Response(isValid: response, canEditProfile: canEditProfile)) - } + func checkDuplication(with request: Models.CheckNicknameDuplication.Request) async -> Bool { + guard let response = await userWorker?.checkNotDuplication(for: request.nickname) else { + os_log(.error, log: .data, "checkDuplication Server Error") + return false + } + didCheckedNicknameDuplicate = response + let canEditProfile = didCheckedNicknameDuplicate && nicknameState == .valid && introduceState == .valid + await MainActor.run { + presenter?.presentNicknameDuplication(with: Models.CheckNicknameDuplication.Response(isValid: response, canEditProfile: canEditProfile)) } + return true } private func profileImageEditRequest(into imageData: Data, fileExtension: String) async -> Bool { @@ -129,43 +128,42 @@ final class EditProfileInteractor: EditProfileBusinessLogic, EditProfileDataStor } @discardableResult - func editProfile(with request: Models.EditProfile.Request) -> Task { - Task { - async let isSuccessNicknameEdit = nicknameEditRequest(into: request.nickname) - async let isSuccessIntroduceEdit = introduceEditRequest(into: request.introduce) - - guard await isSuccessNicknameEdit, await isSuccessIntroduceEdit else { - await MainActor.run { - presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) - } - return false + func editProfile(with request: Models.EditProfile.Request) async -> Bool { + + async let isSuccessNicknameEdit = nicknameEditRequest(into: request.nickname) + async let isSuccessIntroduceEdit = introduceEditRequest(into: request.introduce) + + guard await isSuccessNicknameEdit, await isSuccessIntroduceEdit else { + await MainActor.run { + presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) } + return false + } - // 이미지 변경 요청 - if request.changeProfileImageNeeded { - if let profileImageData = request.profileImageData, let profileImageExtension = request.profileImageExtension { - guard await profileImageEditRequest(into: profileImageData, fileExtension: profileImageExtension) else { - await MainActor.run { - presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) - } - return false + // 이미지 변경 요청 + if request.changeProfileImageNeeded { + if let profileImageData = request.profileImageData, let profileImageExtension = request.profileImageExtension { + guard await profileImageEditRequest(into: profileImageData, fileExtension: profileImageExtension) else { + await MainActor.run { + presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) } - } else { // 이미지 데이터 없는 경우 이미지 삭제 시도 - guard await userWorker?.setProfileImageDefault() == true else { - await MainActor.run { - presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) - } - return false + return false + } + } else { // 이미지 데이터 없는 경우 이미지 삭제 시도 + guard await userWorker?.setProfileImageDefault() == true else { + await MainActor.run { + presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: false)) } - profileImageData = nil + return false } + profileImageData = nil } + } - await MainActor.run { - presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: true)) - } - return true + await MainActor.run { + presenter?.presentProfile(with: Models.EditProfile.Response(isSuccess: true)) } + return true } private func nicknameEditRequest(into nickname: String) async -> Bool { diff --git a/iOS/Layover/Layover/Scenes/EditProfile/EditProfileViewController.swift b/iOS/Layover/Layover/Scenes/EditProfile/EditProfileViewController.swift index 8045d49..328dee0 100644 --- a/iOS/Layover/Layover/Scenes/EditProfile/EditProfileViewController.swift +++ b/iOS/Layover/Layover/Scenes/EditProfile/EditProfileViewController.swift @@ -211,7 +211,9 @@ final class EditProfileViewController: BaseViewController { checkDuplicateNicknameButton.isEnabled = false let request = Models.CheckNicknameDuplication.Request(nickname: nickname) - interactor?.checkDuplication(with: request) + Task { + await interactor?.checkDuplication(with: request) + } } @objc private func editProfileImageButtonDidTap() { @@ -229,7 +231,9 @@ final class EditProfileViewController: BaseViewController { profileImageData: changedProfileImageData, profileImageExtension: changedProfileImageExtension) showLoading() - interactor?.editProfile(with: request) + Task { + await interactor?.editProfile(with: request) + } } } diff --git a/iOS/Layover/Layover/Scenes/Home/HomeInteractor.swift b/iOS/Layover/Layover/Scenes/Home/HomeInteractor.swift index a0aaf8d..58dadc4 100644 --- a/iOS/Layover/Layover/Scenes/Home/HomeInteractor.swift +++ b/iOS/Layover/Layover/Scenes/Home/HomeInteractor.swift @@ -10,7 +10,7 @@ import UIKit protocol HomeBusinessLogic { @discardableResult - func fetchPosts(with request: HomeModels.FetchPosts.Request) -> Task + func fetchPosts(with request: HomeModels.FetchPosts.Request) async -> Bool func playPosts(with request: HomeModels.PlayPosts.Request) func selectVideo(with request: HomeModels.SelectVideo.Request) func showTagPlayList(with request: HomeModels.ShowTagPlayList.Request) @@ -46,18 +46,16 @@ final class HomeInteractor: HomeDataStore { extension HomeInteractor: HomeBusinessLogic { @discardableResult - func fetchPosts(with request: Models.FetchPosts.Request) -> Task { - Task { - guard let posts = await homeWorker?.fetchPosts() else { return false } - let response = Models.FetchPosts.Response(posts: posts) + func fetchPosts(with request: Models.FetchPosts.Request) async -> Bool { + guard let posts = await homeWorker?.fetchPosts() else { return false } + let response = Models.FetchPosts.Response(posts: posts) - await MainActor.run { - self.posts = posts - presenter?.presentPosts(with: response) - } - - return true + await MainActor.run { + self.posts = posts + presenter?.presentPosts(with: response) } + + return true } func playPosts(with request: HomeModels.PlayPosts.Request) { diff --git a/iOS/Layover/Layover/Scenes/Home/HomeViewController.swift b/iOS/Layover/Layover/Scenes/Home/HomeViewController.swift index bb3842c..9f2594b 100644 --- a/iOS/Layover/Layover/Scenes/Home/HomeViewController.swift +++ b/iOS/Layover/Layover/Scenes/Home/HomeViewController.swift @@ -189,7 +189,9 @@ final class HomeViewController: BaseViewController { // MARK: - Use Case private func fetchCarouselVideos() { - interactor?.fetchPosts(with: Models.FetchPosts.Request()) + Task { + await interactor?.fetchPosts(with: Models.FetchPosts.Request()) + } } } diff --git a/iOS/Layover/Layover/Scenes/Profile/ProfileInteractor.swift b/iOS/Layover/Layover/Scenes/Profile/ProfileInteractor.swift index 21a3254..fd750b1 100644 --- a/iOS/Layover/Layover/Scenes/Profile/ProfileInteractor.swift +++ b/iOS/Layover/Layover/Scenes/Profile/ProfileInteractor.swift @@ -10,11 +10,9 @@ import Foundation protocol ProfileBusinessLogic { @discardableResult - func fetchProfile(with request: ProfileModels.FetchProfile.Request) -> Task - + func fetchProfile(with request: ProfileModels.FetchProfile.Request) async -> Bool @discardableResult - func fetchMorePosts(with request: ProfileModels.FetchMorePosts.Request) -> Task - + func fetchMorePosts(with request: ProfileModels.FetchMorePosts.Request) async -> Bool func showPostDetail(with request: ProfileModels.ShowPostDetail.Request) } @@ -53,58 +51,53 @@ final class ProfileInteractor: ProfileBusinessLogic, ProfileDataStore { // MARK: - Methods @discardableResult - func fetchProfile(with request: ProfileModels.FetchProfile.Request) -> Task { + func fetchProfile(with request: ProfileModels.FetchProfile.Request) async -> Bool { fetchPostsPage = 1 canFetchMorePosts = true posts = [] - - return Task { - guard let userProfile = await userWorker?.fetchProfile(by: profileId) else { - return false - } - nickname = userProfile.username - introduce = userProfile.introduce + guard let userProfile = await userWorker?.fetchProfile(by: profileId) else { + return false + } + nickname = userProfile.username + introduce = userProfile.introduce - let posts = await fetchPosts() - canFetchMorePosts = !posts.isEmpty - fetchPostsPage += 1 + let posts = await fetchPosts() + canFetchMorePosts = !posts.isEmpty + fetchPostsPage += 1 - var imageData: Data? = nil - if let profileImageURL = userProfile.profileImageURL { - imageData = await userWorker?.fetchImageData(with: profileImageURL) - } - profileImageData = imageData - let response = Models.FetchProfile.Response(userProfile: ProfileModels.Profile(username: userProfile.username, - introduce: userProfile.introduce, - profileImageData: imageData), - displayedPosts: posts) - await MainActor.run { - presenter?.presentProfile(with: response) - } - return true + var imageData: Data? = nil + if let profileImageURL = userProfile.profileImageURL { + imageData = await userWorker?.fetchImageData(with: profileImageURL) } + profileImageData = imageData + let response = Models.FetchProfile.Response(userProfile: ProfileModels.Profile(username: userProfile.username, + introduce: userProfile.introduce, + profileImageData: imageData), + displayedPosts: posts) + await MainActor.run { + presenter?.presentProfile(with: response) + } + return true } @discardableResult - func fetchMorePosts(with request: ProfileModels.FetchMorePosts.Request) -> Task { - Task { - guard canFetchMorePosts else { return false } - let fetchedPosts = await fetchPosts() - fetchPostsPage += 1 - - if fetchedPosts.isEmpty { - canFetchMorePosts = false - return false - } - - let response = Models.FetchMorePosts.Response(displayedPosts: fetchedPosts) + func fetchMorePosts(with request: ProfileModels.FetchMorePosts.Request) async -> Bool { + guard canFetchMorePosts else { return false } + let fetchedPosts = await fetchPosts() + fetchPostsPage += 1 + + if fetchedPosts.isEmpty { + canFetchMorePosts = false + return false + } - await MainActor.run { - presenter?.presentMorePosts(with: response) - } + let response = Models.FetchMorePosts.Response(displayedPosts: fetchedPosts) - return true + await MainActor.run { + presenter?.presentMorePosts(with: response) } + + return true } private func fetchPosts() async -> [Models.DisplayedPost] { diff --git a/iOS/Layover/Layover/Scenes/Profile/ProfileViewController.swift b/iOS/Layover/Layover/Scenes/Profile/ProfileViewController.swift index bebd22a..8bafdd1 100644 --- a/iOS/Layover/Layover/Scenes/Profile/ProfileViewController.swift +++ b/iOS/Layover/Layover/Scenes/Profile/ProfileViewController.swift @@ -203,11 +203,15 @@ final class ProfileViewController: BaseViewController { // MARK: - Use Case private func fetchProfile() { - interactor?.fetchProfile(with: Models.FetchProfile.Request()) + Task { + await interactor?.fetchProfile(with: Models.FetchProfile.Request()) + } } private func fetchPosts() { - interactor?.fetchMorePosts(with: Models.FetchMorePosts.Request()) + Task { + await interactor?.fetchMorePosts(with: Models.FetchMorePosts.Request()) + } } // MARK: - Actions diff --git a/iOS/Layover/Layover/Scenes/Setting/SettingInteractor.swift b/iOS/Layover/Layover/Scenes/Setting/SettingInteractor.swift index 038d952..264a692 100644 --- a/iOS/Layover/Layover/Scenes/Setting/SettingInteractor.swift +++ b/iOS/Layover/Layover/Scenes/Setting/SettingInteractor.swift @@ -16,7 +16,7 @@ protocol SettingBusinessLogic { func performTableViewConfigure(request: SettingModels.ConfigureTableView.Request) func performUserLogout(request: SettingModels.Logout.Request) @discardableResult - func performUserWithdraw(request: SettingModels.Withdraw.Request) -> Task + func performUserWithdraw(request: SettingModels.Withdraw.Request) async -> Bool } protocol SettingDataStore { @@ -45,14 +45,12 @@ final class SettingInteractor: SettingBusinessLogic, SettingDataStore { } @discardableResult - func performUserWithdraw(request: SettingModels.Withdraw.Request) -> Task { - Task { - guard (await userWorker?.withdraw()) != nil else { return false } - userWorker?.logout() - await MainActor.run { - presenter?.presentUserWithdrawConfirmed(with: Models.Withdraw.Response()) - } - return true + func performUserWithdraw(request: SettingModels.Withdraw.Request) async -> Bool { + guard (await userWorker?.withdraw()) != nil else { return false } + userWorker?.logout() + await MainActor.run { + presenter?.presentUserWithdrawConfirmed(with: Models.Withdraw.Response()) } + return true } } diff --git a/iOS/Layover/Layover/Scenes/Setting/SettingViewController.swift b/iOS/Layover/Layover/Scenes/Setting/SettingViewController.swift index 1880cc8..540a468 100644 --- a/iOS/Layover/Layover/Scenes/Setting/SettingViewController.swift +++ b/iOS/Layover/Layover/Scenes/Setting/SettingViewController.swift @@ -38,7 +38,9 @@ final class SettingViewController: BaseViewController { private lazy var withdrawAlertController: UIAlertController = { let alertController = UIAlertController(title: "회원탈퇴", message: "7일 내로 재로그인시 계정이 복구됩니다.\n정말 탈퇴하시겠어요?", preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "탈퇴", style: .destructive, handler: { [weak self] _ in - self?.interactor?.performUserWithdraw(request: Models.Withdraw.Request()) + Task { + await self?.interactor?.performUserWithdraw(request: Models.Withdraw.Request()) + } })) alertController.addAction(UIAlertAction(title: "취소", style: .cancel, handler: nil)) return alertController diff --git a/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListInteractor.swift b/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListInteractor.swift index beab3e2..deb0ca8 100644 --- a/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListInteractor.swift +++ b/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListInteractor.swift @@ -12,9 +12,9 @@ import OSLog protocol TagPlayListBusinessLogic { func setTitleTag(request: TagPlayListModels.FetchTitleTag.Request) @discardableResult - func fetchPlayList(request: TagPlayListModels.FetchPosts.Request) -> Task + func fetchPlayList(request: TagPlayListModels.FetchPosts.Request) async -> Bool @discardableResult - func fetchMorePlayList(request: TagPlayListModels.FetchMorePosts.Request) -> Task + func fetchMorePlayList(request: TagPlayListModels.FetchMorePosts.Request) async -> Bool func showPostsDetail(request: TagPlayListModels.ShowPostsDetail.Request) } @@ -48,43 +48,39 @@ final class TagPlayListInteractor: TagPlayListBusinessLogic, TagPlayListDataStor } @discardableResult - func fetchPlayList(request: Models.FetchPosts.Request) -> Task { - Task { - fetchPostsPage = 1 - guard let titleTag = titleTag, - let fetchedPosts = await worker?.fetchPlayList(of: titleTag, at: fetchPostsPage) else { return false } - posts = fetchedPosts - fetchPostsPage += 1 - canFetchMorePosts = !fetchedPosts.isEmpty - - let responsePosts = await transformDisplayedPost(with: fetchedPosts) - - await MainActor.run { - presenter?.presentPlayList(response: Models.FetchPosts.Response(post: responsePosts)) - } - - return true + func fetchPlayList(request: Models.FetchPosts.Request) async -> Bool { + fetchPostsPage = 1 + guard let titleTag = titleTag, + let fetchedPosts = await worker?.fetchPlayList(of: titleTag, at: fetchPostsPage) else { return false } + posts = fetchedPosts + fetchPostsPage += 1 + canFetchMorePosts = !fetchedPosts.isEmpty + + let responsePosts = await transformDisplayedPost(with: fetchedPosts) + + await MainActor.run { + presenter?.presentPlayList(response: Models.FetchPosts.Response(post: responsePosts)) } + + return true } @discardableResult - func fetchMorePlayList(request: Models.FetchMorePosts.Request) -> Task { - Task { - guard canFetchMorePosts, - let titleTag = titleTag, - let posts = await worker?.fetchPlayList(of: titleTag, at: fetchPostsPage) else { return false } - self.posts.append(contentsOf: posts) - fetchPostsPage += 1 - canFetchMorePosts = !posts.isEmpty - - let responsePosts = await transformDisplayedPost(with: posts) - - await MainActor.run { - presenter?.presentMorePlayList(response: Models.FetchMorePosts.Response(post: responsePosts)) - } - - return true + func fetchMorePlayList(request: Models.FetchMorePosts.Request) async -> Bool { + guard canFetchMorePosts, + let titleTag = titleTag, + let posts = await worker?.fetchPlayList(of: titleTag, at: fetchPostsPage) else { return false } + self.posts.append(contentsOf: posts) + fetchPostsPage += 1 + canFetchMorePosts = !posts.isEmpty + + let responsePosts = await transformDisplayedPost(with: posts) + + await MainActor.run { + presenter?.presentMorePlayList(response: Models.FetchMorePosts.Response(post: responsePosts)) } + + return true } func showPostsDetail(request: Models.ShowPostsDetail.Request) { diff --git a/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListViewController.swift b/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListViewController.swift index 0463696..67d8a3a 100644 --- a/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListViewController.swift +++ b/iOS/Layover/Layover/Scenes/TagPlayList/TagPlayListViewController.swift @@ -119,7 +119,9 @@ final class TagPlayListViewController: BaseViewController { } private func fetchPlayList() { - interactor?.fetchPlayList(request: Models.FetchPosts.Request()) + Task { + await interactor?.fetchPlayList(request: Models.FetchPosts.Request()) + } } } @@ -132,7 +134,9 @@ extension TagPlayListViewController: UICollectionViewDelegate { let height = scrollView.bounds.height if scrollOffset > contentHeight - height { - interactor?.fetchMorePlayList(request: Models.FetchMorePosts.Request()) + Task { + await interactor?.fetchMorePlayList(request: Models.FetchMorePosts.Request()) + } } } diff --git a/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift index 0541905..7d6a36e 100644 --- a/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Home/HomeInteractorTests.swift @@ -64,7 +64,7 @@ final class HomeInteractorTests: XCTestCase { let request = Models.FetchPosts.Request() // Act - _ = await sut.fetchPosts(with: request).value + await sut.fetchPosts(with: request) // Assert XCTAssertTrue(spy.presentPostsCalled, "fetchPost()가 presenter의 presentPosts()를 호출하지 못했다.") @@ -85,7 +85,7 @@ final class HomeInteractorTests: XCTestCase { XCTAssertEqual(spy.presentPostsReceivedResponse.posts[0].member.identifier, Seeds.Posts.post1.member.identifier, "fetchPost()가 presenter에게 올바른 데이터를 저장하지 못했다.") } - func test_playPosts는_자신의_selectedIndex값을_변경한다() async throws { + func test_playPosts는_자신의_selectedIndex값을_변경한다() { // Arrange let request = Models.PlayPosts.Request(selectedIndex: 101) @@ -96,7 +96,7 @@ final class HomeInteractorTests: XCTestCase { XCTAssertEqual(sut.postPlayStartIndex, 101, "playPosts()가 자신의 selectedIndex를 변경하지 못했다.") } - func test_playPosts는_presenter의_presentPlaybackScene를_호출한다() async throws { + func test_playPosts는_presenter의_presentPlaybackScene를_호출한다() { // Arrange let spy = HomePresentationLogicSpy() sut.presenter = spy diff --git a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift index d3758b1..aee566c 100644 --- a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileInteractorTests.swift @@ -72,7 +72,7 @@ final class ProfileInteractorTests: XCTestCase { sut.presenter = presentationLogicSpy // act - _ = await sut.fetchProfile(with: Models.FetchProfile.Request()).value + await sut.fetchProfile(with: Models.FetchProfile.Request()) // assert XCTAssertTrue(presentationLogicSpy.presentProfileCalled, "fetchProfile을 호출해서 presentProfile을 호출하지 못했다") @@ -91,7 +91,7 @@ final class ProfileInteractorTests: XCTestCase { sut.presenter = presentationLogicSpy // act - _ = await sut.fetchMorePosts(with: Models.FetchMorePosts.Request()).value + await sut.fetchMorePosts(with: Models.FetchMorePosts.Request()) // assert XCTAssertTrue(presentationLogicSpy.presentMorePostsCalled, "fetchMorePosts을 호출해서 presentMorePosts을 호출하지 못했다") @@ -101,7 +101,7 @@ final class ProfileInteractorTests: XCTestCase { XCTAssertEqual(presentationLogicSpy.presentMorePostsResponse.displayedPosts[0].status, Seeds.Posts.post1.board.status, "presentMorePostsResponse에는 fetchMorePosts의 결과가 올바르게 담기지 못했다") } - func test_showPostDetail을_호출하면_자신의_playbackStartIndex에_값을_저장하고_presenter의_presentPostDetail을_호출한다() async { + func test_showPostDetail을_호출하면_자신의_playbackStartIndex에_값을_저장하고_presenter의_presentPostDetail을_호출한다() { // arrange let presentationLogicSpy = ProfilePresentationLogicSpy() sut.presenter = presentationLogicSpy diff --git a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift index 5678a44..d498c63 100644 --- a/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Profile/ProfileViewControllerTests.swift @@ -40,18 +40,14 @@ final class ProfileViewControllerTests: XCTestCase { var showPostDetailCalled = false var showPostDetailRequest: Models.ShowPostDetail.Request! - func fetchProfile(with request: Models.FetchProfile.Request) -> Task { + func fetchProfile(with request: Models.FetchProfile.Request) async -> Bool { fetchProfileCalled = true - return Task { - return true - } + return true } - func fetchMorePosts(with request: Models.FetchMorePosts.Request) -> Task { + func fetchMorePosts(with request: Models.FetchMorePosts.Request) async -> Bool { fetchMorePostsCalled = true - return Task { - return true - } + return true } func showPostDetail(with request: Models.ShowPostDetail.Request) { @@ -72,7 +68,10 @@ final class ProfileViewControllerTests: XCTestCase { sut.viewWillAppear(false) // assert - XCTAssertTrue(spy.fetchProfileCalled, "viewWillAppear가 호출되어 fetchProfile를 호출하지 못했다") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertTrue(spy.fetchProfileCalled, "viewWillAppear가 호출되어 fetchProfile를 호출하지 못했다") + } } func test_스크롤이_바닥에_닿아_scrollViewBeginDecelerating이_호출되면_fetchMorePosts가_호출된다() { @@ -88,7 +87,10 @@ final class ProfileViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // assert - XCTAssertTrue(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿아 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출하지 못했다") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertTrue(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿아 scrollViewBeginDecelerating이 호출되어 fetchPosts를 호출하지 못했다") + } } func test_스크롤이_바닥에_닿지_않고_scrollViewBeginDecelerating이_호출되면_fetchMorePosts가_호출된다() { @@ -104,7 +106,7 @@ final class ProfileViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // assert - XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿지 않고 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출되었다") + XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 바닥에 닿지 않고 scrollViewBeginDecelerating이 호출되어 fetchMorePosts가 호출되었다") } func test_스크롤을_아래로_당겨서_scrollViewBeginDecelerating이_호출되면_fetchMorePosts가_호출되지_않았다() { @@ -120,6 +122,6 @@ final class ProfileViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // assert - XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 아래로 당겨져서 scrollViewBeginDecelerating이 호출되어 fetchPosts가 호출되었다") + XCTAssertFalse(spy.fetchMorePostsCalled, "스크롤이 아래로 당겨져서 scrollViewBeginDecelerating이 호출되어 fetchMorePosts가 호출되었다") } } diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift index 94f9e04..b5a81ea 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingInteractorTests.swift @@ -88,15 +88,14 @@ final class SettingInteractorTests: XCTestCase { XCTAssertTrue(spy.presentUserLogoutConfirmedCalled, "performUserLogout()를 실행해서 presenter의 presentUserLogoutConfirmed()를 호출되지 못했다.") } - func test_performUserWithdraw를_실행하면_presenter의_presentUserWithdrawConfirmed가_호출된다() async throws { + func test_performUserWithdraw를_실행하면_presenter의_presentUserWithdrawConfirmed가_호출된다() async { // arrange let spy = SettingPresentationLogicSpy() sut.presenter = spy let request = Models.Withdraw.Request() // act - sut.performUserWithdraw(request: request) - try await Task.sleep(nanoseconds: 3_000_000_000) + await sut.performUserWithdraw(request: request) // assert XCTAssertTrue(spy.presentUserWithdrawConfirmedCalled, "performUserWithdraw()를 실행해서 presenter의 presentUserWithdrawConfirmed()가 호출되지 못했다.") diff --git a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift index e8f3813..f952c1c 100644 --- a/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/Setting/SettingViewControllerTests.swift @@ -46,11 +46,9 @@ final class SettingViewControllerTests: XCTestCase { performUserLogoutCalled = true } - func performUserWithdraw(request: Layover.SettingModels.Withdraw.Request) -> Task { + func performUserWithdraw(request: Layover.SettingModels.Withdraw.Request) async -> Bool { performUserWithdrawCalled = true - return Task { - true - } + return true } } diff --git a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift index 6f687de..b1fe4bd 100644 --- a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListInteractorTests.swift @@ -98,7 +98,7 @@ final class TagPlayListInteractorTests: XCTestCase { let request = Models.FetchPosts.Request() // Act - _ = await sut.fetchPlayList(request: request).value + await sut.fetchPlayList(request: request) // Assert XCTAssertTrue(spy.presentPlayListCalled, "fetchPlayList()가 presenter의 presentPlayList()를 호출했다.") @@ -131,7 +131,7 @@ final class TagPlayListInteractorTests: XCTestCase { sut.posts = [Seeds.Posts.post2] // Act - _ = await sut.fetchPlayList(request: request).value + await sut.fetchPlayList(request: request) // Assert XCTAssert(!sut.posts.contains(where: { @@ -174,7 +174,7 @@ final class TagPlayListInteractorTests: XCTestCase { let fetchMoreRequest = Models.FetchMorePosts.Request() // Act - _ = await sut.fetchMorePlayList(request: fetchMoreRequest).value + await sut.fetchMorePlayList(request: fetchMoreRequest) // Assert XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") @@ -191,9 +191,9 @@ final class TagPlayListInteractorTests: XCTestCase { let request = Models.FetchMorePosts.Request() // Act -> 3번 호출 이후 빈 배열을 반환하도록 Mocking됨 - _ = await sut.fetchMorePlayList(request: request).value - _ = await sut.fetchMorePlayList(request: request).value - _ = await sut.fetchMorePlayList(request: request).value + await sut.fetchMorePlayList(request: request) + await sut.fetchMorePlayList(request: request) + await sut.fetchMorePlayList(request: request) // Assert XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") @@ -210,7 +210,7 @@ final class TagPlayListInteractorTests: XCTestCase { let request = Models.FetchMorePosts.Request() // Act - _ = await sut.fetchMorePlayList(request: request).value + await sut.fetchMorePlayList(request: request) // Assert XCTAssertTrue(spy.presentMorePlayListCalled, "fetchPlayMoreList()가 presenter의 presentMorePlayList()를 호출하지 못했다.") diff --git a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift index 5f27bdd..f97c334 100644 --- a/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift +++ b/iOS/Layover/LayoverTests/Scenes/TagPlayList/TagPlayListViewControllerTests.swift @@ -55,20 +55,14 @@ final class TagPlayListViewControllerTests: XCTestCase { setTitleTagCalled = true } - func fetchPlayList(request: Layover.TagPlayListModels.FetchPosts.Request) -> Task { + func fetchPlayList(request: Layover.TagPlayListModels.FetchPosts.Request) async -> Bool { fetchPlayListCalled = true - - return Task { - return true - } + return true } - func fetchMorePlayList(request: Layover.TagPlayListModels.FetchMorePosts.Request) -> Task { + func fetchMorePlayList(request: Layover.TagPlayListModels.FetchMorePosts.Request) async -> Bool { fetchMorePlayListCalled = true - - return Task { - return true - } + return true } func showPostsDetail(request: Layover.TagPlayListModels.ShowPostsDetail.Request) { @@ -109,7 +103,10 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.viewWillAppear(true) // Assert - XCTAssertTrue(spy.fetchPlayListCalled, "viewWillAppear()가 호출되어 interactor의 fetchPlayList를 호출하지 못했다.") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertTrue(spy.fetchPlayListCalled, "viewWillAppear()가 호출되어 interactor의 fetchPlayList를 호출하지 못했다.") + } } func test_scrollView가_아래_끝에_다다라_scrollViewWillBeginDecelearting가_호출되면_interactor의_fetchMorePlayList를_호출한다() { @@ -124,7 +121,10 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // Assert - XCTAssertTrue(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다라 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출하지 못했다.") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertTrue(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다라 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출하지 못했다.") + } } func test_scrollView가_아래_끝에_다다르지_않은_상태에서_scrollViewWillBeginDecelearting가_호출되면_interactor의_fetchMorePlayList를_호출하지_않는다() { @@ -139,7 +139,10 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.scrollViewWillBeginDecelerating(scrollView) // Assert - XCTAssertFalse(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다르지 않고 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출했다.") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertFalse(spy.fetchMorePlayListCalled, "scrollView가 아래 끝에 다다르지 않고 scrollViewWillBeginDecelerating() 이 호출되어 interactor의 fetchMorePlayList를 호출했다.") + } } func test_collectionView의_didSelectItemAt이_호출되면_interactor에게_showPostsDetail를_요청한다() { @@ -152,7 +155,10 @@ final class TagPlayListViewControllerTests: XCTestCase { sut.collectionView(collectionView, didSelectItemAt: IndexPath(item: 0, section: 0)) // Assert - XCTAssertTrue(spy.showPostsDetailCalled, "collectionView의 didSelectItemAt을 호출해서 interactor에게 showPostsDetail를 요청하지 못했다.") + Task { + try await Task.sleep(nanoseconds: 3_000_000_000) + XCTAssertTrue(spy.showPostsDetailCalled, "collectionView의 didSelectItemAt을 호출해서 interactor에게 showPostsDetail를 요청하지 못했다.") + } } func test_collectionView의_didSelectItemAt이_호출되면_router에게_routeToPlayback을_요청한다() {