Skip to content

Commit

Permalink
test. 데이터 들어가는 경우에 대한 테스트 케이스
Browse files Browse the repository at this point in the history
DispatchQueue를 사용하지 않는 방법에서 막힘
  • Loading branch information
Peter1119 committed Jan 23, 2024
1 parent 499aa10 commit f510817
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

protocol ModelStore {
associatedtype Model: Identifiable
var isEmpty: Bool
var isEmpty: Bool { get }

func fetchByID(_ id: Model.ID) -> Model?
}
Expand Down
50 changes: 50 additions & 0 deletions RaiseMeUp/RaiseMeUpTests/MainViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

}
}

0 comments on commit f510817

Please sign in to comment.