@@ -47,31 +47,57 @@ struct TotalsViewHelperTests {
4747 }
4848
4949 @Test ( arguments: [
50- ( PointOfSaleOrderState . idle, PointOfSalePaymentState . card ( . idle) ) ,
51- ( PointOfSaleOrderState . idle, PointOfSalePaymentState . card ( . validatingOrder) ) ,
52- ( PointOfSaleOrderState . idle, PointOfSalePaymentState . card ( . validatingOrderError) ) ,
53- ( PointOfSaleOrderState . idle, PointOfSalePaymentState . card ( . preparingReader) ) ,
54- ( PointOfSaleOrderState . idle, PointOfSalePaymentState . card ( . acceptingCard) )
50+ ( PointOfSalePaymentState . card ( . validatingOrderError) ) ,
51+ ( PointOfSalePaymentState . card ( . acceptingCard) )
5552 ] )
5653 func test_shouldShowCollectCashPaymentButton_returns_true_for_supported_states(
57- orderState: PointOfSaleOrderState ,
5854 paymentState: PointOfSalePaymentState ) {
59- #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: orderState,
60- paymentState: paymentState) )
55+ #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: . loaded( . init( cartTotal: " 10 " ,
56+ orderTotal: " 10 " ,
57+ taxTotal: " 10 " ,
58+ orderTotalDecimal: 0 ) ) ,
59+ paymentState: paymentState,
60+ cardReaderConnectionStatus: . connected( . init( name: " " , batteryLevel: nil ) ) ) )
6161 }
6262
63+ @Test
64+ func test_shouldShowCollectCashPaymentButton_returns_true_for_idle_when_reader_disconnected( ) {
65+ #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: . loaded( . init( cartTotal: " 10 " ,
66+ orderTotal: " 10 " ,
67+ taxTotal: " 10 " ,
68+ orderTotalDecimal: 0 ) ) ,
69+ paymentState: . card( . idle) ,
70+ cardReaderConnectionStatus: . disconnected) )
71+ }
72+
73+ @Test
74+ func test_shouldShowCollectCashPaymentButton_returns_true_for_idle_when_reader_connected_but_order_zero( ) {
75+ #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: . loaded( . init( cartTotal: " 0 " ,
76+ orderTotal: " 0 " ,
77+ taxTotal: " 0 " ,
78+ orderTotalDecimal: 0 ) ) ,
79+ paymentState: . card( . idle) ,
80+ cardReaderConnectionStatus: . connected( . init( name: " " , batteryLevel: nil ) ) ) )
81+ }
82+
83+ @Test
84+ func test_shouldShowCollectCashPaymentButton_returns_false_for_idle_when_reader_connected_but_order_not_zero( ) {
85+ #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: . loaded( . init( cartTotal: " 10 " ,
86+ orderTotal: " 10 " ,
87+ taxTotal: " 10 " ,
88+ orderTotalDecimal: 10 ) ) ,
89+ paymentState: . card( . idle) ,
90+ cardReaderConnectionStatus: . connected( . init( name: " " , batteryLevel: nil ) ) ) == false )
91+ }
6392
6493 @Test ( arguments: [
65- ( PointOfSaleOrderState . syncing, PointOfSalePaymentState . card ( . idle) ) ,
66- ( PointOfSaleOrderState . syncing, PointOfSalePaymentState . card ( . validatingOrder) ) ,
67- ( PointOfSaleOrderState . syncing, PointOfSalePaymentState . card ( . validatingOrderError) ) ,
68- ( PointOfSaleOrderState . syncing, PointOfSalePaymentState . card ( . preparingReader) ) ,
69- ( PointOfSaleOrderState . syncing, PointOfSalePaymentState . card ( . acceptingCard) )
94+ ( PointOfSalePaymentState . card ( . validatingOrderError) ) ,
95+ ( PointOfSalePaymentState . card ( . acceptingCard) )
7096 ] )
7197 func test_shouldShowCollectCashPaymentButton_returns_false_when_order_syncing(
72- orderState: PointOfSaleOrderState ,
7398 paymentState: PointOfSalePaymentState ) {
74- #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: orderState,
75- paymentState: paymentState) == false )
99+ #expect( TotalsViewHelper ( ) . shouldShowCollectCashPaymentButton ( orderState: . syncing,
100+ paymentState: paymentState,
101+ cardReaderConnectionStatus: . connected( . init( name: " " , batteryLevel: nil ) ) ) == false )
76102 }
77103}
0 commit comments