@@ -31,6 +31,12 @@ describe('Poker', () => {
3131 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
3232 } ) ;
3333
34+ xtest ( 'winning high card hand also has the lowest card' , ( ) => {
35+ const hands = [ '2S 5H 6S 8D 7H' , '3S 4D 6D 8C 7S' ] ;
36+ const expected = [ '2S 5H 6S 8D 7H' ] ;
37+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
38+ } ) ;
39+
3440 xtest ( 'one pair beats high card' , ( ) => {
3541 const hands = [ '4S 5H 6C 8D KH' , '2S 4H 6S 4D JH' ] ;
3642 const expected = [ '2S 4H 6S 4D JH' ] ;
@@ -43,6 +49,12 @@ describe('Poker', () => {
4349 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
4450 } ) ;
4551
52+ xtest ( 'both hands have the same pair, high card wins' , ( ) => {
53+ const hands = [ '4H 4S AH JC 3D' , '4C 4D AS 5D 6C' ] ;
54+ const expected = [ '4H 4S AH JC 3D' ] ;
55+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
56+ } ) ;
57+
4658 xtest ( 'two pairs beats one pair' , ( ) => {
4759 const hands = [ '2S 8H 6S 8D JH' , '4S 5H 4C 8C 5C' ] ;
4860 const expected = [ '4S 5H 4C 8C 5C' ] ;
@@ -67,6 +79,18 @@ describe('Poker', () => {
6779 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
6880 } ) ;
6981
82+ xtest ( 'both hands have two pairs that add to the same value, win goes to highest pair' , ( ) => {
83+ const hands = [ '6S 6H 3S 3H AS' , '7H 7S 2H 2S AC' ] ;
84+ const expected = [ '7H 7S 2H 2S AC' ] ;
85+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
86+ } ) ;
87+
88+ xtest ( 'two pairs first ranked by largest pair' , ( ) => {
89+ const hands = [ '5C 2S 5S 4H 4C' , '6S 2S 6H 7C 2C' ] ;
90+ const expected = [ '6S 2S 6H 7C 2C' ] ;
91+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
92+ } ) ;
93+
7094 xtest ( 'three of a kind beats two pair' , ( ) => {
7195 const hands = [ '2S 8H 2H 8D JH' , '4S 5H 4C 8S 4H' ] ;
7296 const expected = [ '4S 5H 4C 8S 4H' ] ;
@@ -80,7 +104,7 @@ describe('Poker', () => {
80104 } ) ;
81105
82106 xtest ( 'with multiple decks, two players can have same three of a kind, ties go to highest remaining cards' , ( ) => {
83- const hands = [ '4S AH AS 7C AD' , '4S AH AS 8C AD' ] ;
107+ const hands = [ '5S AH AS 7C AD' , '4S AH AS 8C AD' ] ;
84108 const expected = [ '4S AH AS 8C AD' ] ;
85109 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
86110 } ) ;
@@ -103,6 +127,12 @@ describe('Poker', () => {
103127 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
104128 } ) ;
105129
130+ xtest ( 'aces cannot be in the middle of a straight (Q K A 2 3)' , ( ) => {
131+ const hands = [ '2C 3D 7H 5H 2S' , 'QS KH AC 2D 3S' ] ;
132+ const expected = [ '2C 3D 7H 5H 2S' ] ;
133+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
134+ } ) ;
135+
106136 xtest ( 'both hands with a straight, tie goes to highest ranked card' , ( ) => {
107137 const hands = [ '4S 6C 7S 8D 5H' , '5S 7H 8S 9D 6H' ] ;
108138 const expected = [ '5S 7H 8S 9D 6H' ] ;
@@ -122,8 +152,8 @@ describe('Poker', () => {
122152 } ) ;
123153
124154 xtest ( 'both hands have a flush, tie goes to high card, down to the last one if necessary' , ( ) => {
125- const hands = [ '4H 7H 8H 9H 6H' , '2S 4S 5S 6S 7S' ] ;
126- const expected = [ '4H 7H 8H 9H 6H' ] ;
155+ const hands = [ '2H 7H 8H 9H 6H' , '3S 5S 6S 7S 8S ' ] ;
156+ const expected = [ '2H 7H 8H 9H 6H' ] ;
127157 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
128158 } ) ;
129159
@@ -169,9 +199,33 @@ describe('Poker', () => {
169199 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
170200 } ) ;
171201
202+ xtest ( 'aces can end a straight flush (10 J Q K A)' , ( ) => {
203+ const hands = [ 'KC AH AS AD AC' , '10C JC QC KC AC' ] ;
204+ const expected = [ '10C JC QC KC AC' ] ;
205+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
206+ } ) ;
207+
208+ xtest ( 'aces can start a straight flush (A 2 3 4 5)' , ( ) => {
209+ const hands = [ 'KS AH AS AD AC' , '4H AH 3H 2H 5H' ] ;
210+ const expected = [ '4H AH 3H 2H 5H' ] ;
211+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
212+ } ) ;
213+
214+ xtest ( 'aces cannot be in the middle of a straight flush (Q K A 2 3)' , ( ) => {
215+ const hands = [ '2C AC QC 10C KC' , 'QH KH AH 2H 3H' ] ;
216+ const expected = [ '2C AC QC 10C KC' ] ;
217+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
218+ } ) ;
219+
172220 xtest ( 'both hands have straight flush, tie goes to highest-ranked card' , ( ) => {
173221 const hands = [ '4H 6H 7H 8H 5H' , '5S 7S 8S 9S 6S' ] ;
174222 const expected = [ '5S 7S 8S 9S 6S' ] ;
175223 expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
176224 } ) ;
225+
226+ xtest ( 'even though an ace is usually high, a 5-high straight flush is the lowest-scoring straight flush' , ( ) => {
227+ const hands = [ '2H 3H 4H 5H 6H' , '4D AD 3D 2D 5D' ] ;
228+ const expected = [ '2H 3H 4H 5H 6H' ] ;
229+ expect ( bestHands ( hands ) ) . toEqual ( expected ) ;
230+ } ) ;
177231} ) ;
0 commit comments