diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 18:43:09 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 18:43:09 +0100 |
| commit | 08269639606c0481037cbde7ebaf2e0455460883 (patch) | |
| tree | 57c1f967e8836a1a7da84b1887d932e0067d538f /tests/client_core.rs | |
| parent | v2.2.0: add blackjack with reserved bets and hit/stand/double (diff) | |
| download | zagan-bet-08269639606c0481037cbde7ebaf2e0455460883.tar.gz zagan-bet-08269639606c0481037cbde7ebaf2e0455460883.zip | |
v2.2.1: forfeit blackjack bets when leaving or disconnecting
Diffstat (limited to 'tests/client_core.rs')
| -rw-r--r-- | tests/client_core.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/client_core.rs b/tests/client_core.rs index cfcf608..ec444bd 100644 --- a/tests/client_core.rs +++ b/tests/client_core.rs | |||
| @@ -722,6 +722,7 @@ fn blackjack_deals_hits_and_settles() { | |||
| 722 | assert!(h.board()[3].contains("You: [10♠] [6♥] 16")); | 722 | assert!(h.board()[3].contains("You: [10♠] [6♥] 16")); |
| 723 | assert!(h.board()[4].contains("Hit, stand or double.")); | 723 | assert!(h.board()[4].contains("Hit, stand or double.")); |
| 724 | assert!(h.board()[5].contains("[D]ouble")); | 724 | assert!(h.board()[5].contains("[D]ouble")); |
| 725 | assert!(h.board()[5].contains("[Q] Forfeit")); | ||
| 725 | 726 | ||
| 726 | h.key(Key::Char('h')); | 727 | h.key(Key::Char('h')); |
| 727 | assert_eq!( | 728 | assert_eq!( |
| @@ -757,7 +758,7 @@ fn blackjack_deals_hits_and_settles() { | |||
| 757 | } | 758 | } |
| 758 | 759 | ||
| 759 | #[test] | 760 | #[test] |
| 760 | fn blackjack_cancel_sends_a_cancel_action() { | 761 | fn blackjack_forfeit_is_sent_when_leaving_an_active_hand() { |
| 761 | let mut h = Harness::new(); | 762 | let mut h = Harness::new(); |
| 762 | h.enter_blackjack(); | 763 | h.enter_blackjack(); |
| 763 | h.key(Key::Char(' ')); | 764 | h.key(Key::Char(' ')); |
| @@ -784,10 +785,10 @@ fn blackjack_cancel_sends_a_cancel_action() { | |||
| 784 | h.key(Key::Char('q')); | 785 | h.key(Key::Char('q')); |
| 785 | assert_eq!( | 786 | assert_eq!( |
| 786 | h.sent.last().map(String::as_str), | 787 | h.sent.last().map(String::as_str), |
| 787 | Some("BLACKJACK_ACTION bj1 cancel") | 788 | Some("BLACKJACK_ACTION bj1 forfeit") |
| 788 | ); | 789 | ); |
| 789 | 790 | ||
| 790 | let cancelled = bj_state( | 791 | let forfeited = bj_state( |
| 791 | "bj1", | 792 | "bj1", |
| 792 | "done", | 793 | "done", |
| 793 | &["10S", "6H"], | 794 | &["10S", "6H"], |
| @@ -796,18 +797,22 @@ fn blackjack_cancel_sends_a_cancel_action() { | |||
| 796 | 9, | 797 | 9, |
| 797 | 10, | 798 | 10, |
| 798 | 10, | 799 | 10, |
| 799 | 1000, | 800 | 990, |
| 800 | &[], | 801 | &[], |
| 801 | "cancelled", | 802 | "forfeit", |
| 802 | 0, | 803 | 0, |
| 803 | ); | 804 | ); |
| 804 | h.reply(&format!( | 805 | h.reply(&format!( |
| 805 | "BLACKJACK_STATE {}", | 806 | "BLACKJACK_STATE {}", |
| 806 | serde_json::to_string(&cancelled).unwrap() | 807 | serde_json::to_string(&forfeited).unwrap() |
| 807 | )); | 808 | )); |
| 808 | 809 | ||
| 809 | assert!(h.board().is_empty()); | 810 | assert!(h.board().is_empty()); |
| 810 | assert!(h.screen.lines.iter().any(|line| line == "Game exited.")); | 811 | assert!(h |
| 812 | .screen | ||
| 813 | .lines | ||
| 814 | .iter() | ||
| 815 | .any(|line| line.contains("forfeited (10 PLN lost)"))); | ||
| 811 | } | 816 | } |
| 812 | 817 | ||
| 813 | #[test] | 818 | #[test] |
