Skip to content

Commit e798902

Browse files
committed
Add tests
1 parent 87cc3ab commit e798902

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Bookings/BookingDetailsViewModelTests.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,31 @@ final class BookingDetailsViewModelTests: XCTestCase {
357357

358358
XCTAssertFalse(containsAttendanceSection)
359359
}
360+
361+
func test_view_order_is_hidden_when_booking_order_id_is_invalid() {
362+
// Given
363+
let booking = Booking.fake().copy(
364+
orderID: 0
365+
)
366+
367+
// When
368+
let viewModel = BookingDetailsViewModel(booking: booking, stores: storesManager)
369+
370+
// Then
371+
let paymentSection = viewModel.sections.first { section in
372+
if case .payment = section.content {
373+
return true
374+
}
375+
return false
376+
}
377+
378+
guard let paymentSection = paymentSection,
379+
case let .payment(paymentContent) = paymentSection.content else {
380+
XCTFail("Payment section not found")
381+
return
382+
}
383+
384+
XCTAssertFalse(viewModel.isViewOrderAvailable)
385+
XCTAssertFalse(paymentContent.actions.contains(.viewOrder))
386+
}
360387
}

0 commit comments

Comments
 (0)