Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
FulcrumOne committed Nov 17, 2024
1 parent ade11eb commit b64536d
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions Tests/Tests+ViewModel+PopupVerticalStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ extension PopupVerticalStackViewModelTests {
await bottomViewModel.updatePopups([
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 150)
])
await waitForResults()

XCTAssertEqual(
bottomViewModel.popups.getInvertedIndex(of: bottomViewModel.popups[0]),
Expand All @@ -70,7 +69,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 150),
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 150)
])
await waitForResults()

XCTAssertEqual(
bottomViewModel.popups.getInvertedIndex(of: bottomViewModel.popups[3]),
Expand Down Expand Up @@ -472,7 +470,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 670),
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 310)
])
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[2]),
Expand All @@ -488,7 +485,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 310)
])
await bottomViewModel.updateGestureTranslation(0)
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[4]),
Expand All @@ -500,7 +496,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 350, popupDragHeight: 100)
])
await bottomViewModel.updateGestureTranslation(-100)
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[0]),
Expand All @@ -513,7 +508,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 133, popupDragHeight: 21)
])
await bottomViewModel.updateGestureTranslation(100)
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[0]),
Expand All @@ -526,7 +520,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 133, popupDragHeight: 21)
])
await bottomViewModel.updateGestureTranslation(100)
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[1]),
Expand All @@ -539,7 +532,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .bottom, heightMode: .auto, popupHeight: 133, popupDragHeight: 21)
])
GlobalConfigContainer.vertical.isStackingEnabled = false
await waitForResults()

XCTAssertEqual(
bottomViewModel.calculateOffsetY(for: bottomViewModel.popups[0]),
Expand All @@ -552,7 +544,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .top, heightMode: .auto, popupHeight: 133, popupDragHeight: 21)
])
await topViewModel.updateGestureTranslation(0)
await waitForResults()

XCTAssertEqual(
topViewModel.calculateOffsetY(for: topViewModel.popups[0]),
Expand All @@ -565,7 +556,6 @@ extension PopupVerticalStackViewModelTests {
createPopupInstanceForPopupHeightTests(alignment: .top, heightMode: .auto, popupHeight: 133, popupDragHeight: 21)
])
await topViewModel.updateGestureTranslation(-100)
await waitForResults()

XCTAssertEqual(
topViewModel.calculateOffsetY(for: topViewModel.popups[1]),
Expand Down Expand Up @@ -1306,9 +1296,7 @@ private extension PopupVerticalStackViewModelTests {
func appendPopupsAndCheckGestureTranslationOnChange(viewModel: ViewModel, popups: [AnyPopup], gestureValue: CGFloat, expectedValues: (popupHeight: CGFloat, gestureTranslation: CGFloat)) async {
await viewModel.updatePopups(popups)
await updatePopups(viewModel)
await waitForResults()
await viewModel.onPopupDragGestureChanged(gestureValue)
await waitForResults()

XCTAssertEqual(viewModel.activePopupProperties.height, expectedValues.popupHeight)
XCTAssertEqual(viewModel.activePopupProperties.gestureTranslation, expectedValues.gestureTranslation)
Expand Down Expand Up @@ -1477,13 +1465,9 @@ extension PopupVerticalStackViewModelTests {
private extension PopupVerticalStackViewModelTests {
func appendPopupsAndCheckGestureTranslationOnEnd(viewModel: ViewModel, popups: [AnyPopup], gestureValue: CGFloat, expectedValues: (popupHeight: CGFloat?, shouldPopupBeDismissed: Bool)) async {
await viewModel.updatePopups(popups)
await waitForResults()
await updatePopups(viewModel)
await waitForResults()
await viewModel.updateGestureTranslation(gestureValue)
await waitForResults()
await viewModel.onPopupDragGestureEnded(gestureValue)
await waitForResults()

XCTAssertEqual(viewModel.popups.count, expectedValues.shouldPopupBeDismissed ? 0 : 1)
XCTAssertEqual(viewModel.activePopupProperties.height, expectedValues.popupHeight)
Expand All @@ -1507,11 +1491,8 @@ private extension PopupVerticalStackViewModelTests {
}
func appendPopupsAndPerformChecks<Value: Equatable & Sendable>(viewModel: ViewModel, popups: [AnyPopup], gestureTranslation: CGFloat, calculatedValue: @escaping (ViewModel) async -> Value, expectedValueBuilder: @escaping (ViewModel) async -> Value) async {
await viewModel.updatePopups(popups)
await waitForResults()
await updatePopups(viewModel)
await waitForResults()
await viewModel.updateGestureTranslation(gestureTranslation)
await waitForResults()

let calculatedValue = await calculatedValue(viewModel)
let expectedValue = await expectedValueBuilder(viewModel)
Expand All @@ -1525,13 +1506,7 @@ private extension PopupVerticalStackViewModelTests {
case .center: fatalError()
}}
func updatePopups(_ viewModel: ViewModel) async {
for popup in viewModel.popups {
await viewModel.updatePopupHeight(popup.height!, popup)
await waitForResults()
}
}
func waitForResults() async {
await Task.sleep(seconds: 0.06)
for popup in viewModel.popups { await viewModel.updatePopupHeight(popup.height!, popup) }
}
}

Expand Down

0 comments on commit b64536d

Please sign in to comment.