Skip to content

Commit

Permalink
test: test_bindLoader_refresh_두_번_이후_stopLoader_할당_확인 stopLoader 선언
Browse files Browse the repository at this point in the history
  • Loading branch information
tmfrlrkvlek committed Dec 1, 2021
1 parent 6b5fd97 commit 36dedb0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions BBus/StationViewModelTests/StationViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,14 @@ class StationViewModelTests: XCTestCase {
calculateUseCase: StationCalculateUseCase(),
arsId: "1")
let expectation = self.expectation(description: "StationViewModel에 처음_데이터를_모두_불러왔을_때_stopLoader가_true로_변경되는지_확인")
var stopLoader: Bool = false

// when
stationViewModel.$stopLoader
.filter({$0})
.first()
.sink(receiveValue: { [weak expectation] _ in
.sink(receiveValue: { [weak expectation] result in
stopLoader = result
expectation?.fulfill()
})
.store(in: &self.cancellables)
Expand All @@ -533,7 +535,7 @@ class StationViewModelTests: XCTestCase {
waitForExpectations(timeout: self.timeout)

// then
XCTAssertEqual(stationViewModel.stopLoader, true)
XCTAssertEqual(stopLoader, true)
}

func test_bindLoader_refresh_두_번_이후_stopLoader_할당_확인() {
Expand All @@ -542,12 +544,14 @@ class StationViewModelTests: XCTestCase {
calculateUseCase: StationCalculateUseCase(),
arsId: "1")
let expectation = self.expectation(description: "StationViewModel에 refresh_두번_이후_때_stopLoader가_true로_변경되는지_확인")
var stopLoader: Bool = false

// when
stationViewModel.$stopLoader
.filter({$0})
.output(at: 1)
.sink(receiveValue: { [weak expectation] _ in
.sink(receiveValue: { [weak expectation] result in
stopLoader = result
expectation?.fulfill()
})
.store(in: &self.cancellables)
Expand All @@ -557,6 +561,6 @@ class StationViewModelTests: XCTestCase {
waitForExpectations(timeout: self.timeout)

// then
XCTAssertEqual(stationViewModel.stopLoader, true)
XCTAssertEqual(stopLoader, true)
}
}

0 comments on commit 36dedb0

Please sign in to comment.