From f5108171b7e864695ed931a0d2fcce336e12101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A9=E1=86=BC=E1=84=89=E1=85=A5=E1=86=A8?= =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB?= Date: Tue, 23 Jan 2024 11:03:58 +0900 Subject: [PATCH] =?UTF-8?q?test.=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EA=B0=80=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DispatchQueue를 사용하지 않는 방법에서 막힘 --- .../Sources/Core/Constant/AnyModelStore.swift | 2 +- .../RaiseMeUpTests/MainViewModelTests.swift | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/RaiseMeUp/RaiseMeUp/Sources/Core/Constant/AnyModelStore.swift b/RaiseMeUp/RaiseMeUp/Sources/Core/Constant/AnyModelStore.swift index 6097344..ac0cf15 100644 --- a/RaiseMeUp/RaiseMeUp/Sources/Core/Constant/AnyModelStore.swift +++ b/RaiseMeUp/RaiseMeUp/Sources/Core/Constant/AnyModelStore.swift @@ -9,7 +9,7 @@ import Foundation protocol ModelStore { associatedtype Model: Identifiable - var isEmpty: Bool + var isEmpty: Bool { get } func fetchByID(_ id: Model.ID) -> Model? } diff --git a/RaiseMeUp/RaiseMeUpTests/MainViewModelTests.swift b/RaiseMeUp/RaiseMeUpTests/MainViewModelTests.swift index 647acdf..9450173 100644 --- a/RaiseMeUp/RaiseMeUpTests/MainViewModelTests.swift +++ b/RaiseMeUp/RaiseMeUpTests/MainViewModelTests.swift @@ -113,4 +113,54 @@ class MockViewModelTests: XCTestCase { showErrorAlertSubscriber.cancel() } + + func test_데이터가들어갔을경우에_sectionStore의데이터가empty가아니다() async { + // given + let mockUseCase = MockTrainingUseCase(result: .success(PullUpProgram(program: [ + TrainingLevel( + id: "321532", + name: "11", + description: "dkjlf", + routine: [ + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]) + ] + ), + TrainingLevel( + id: "6546547", + name: "11", + description: "dkjlf", + routine: [ + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]) + ] + ), + TrainingLevel( + id: "234535", + name: "11", + description: "dkjlf", + routine: [ + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]), + DailyRoutine(day: "1", routine: [1,2,3]) + ] + ) + ]))) + let viewModel = MainViewModel(useCase: mockUseCase) + let expectation = XCTestExpectation(description: "loadPrograms 완료") + + // when + viewModel.loadPrograms() + + + + // then + XCTAssertFalse(viewModel.sectionStore.isEmpty, "section의 모델이 제대로 들어가지 않았다.") + } + + func test_데이터가들어갔을경우에_routineStore의데이터가empty가아니다() async { + + } }