|
3 | 3 | const getCardValue = require("../implement/3-get-card-value"); |
4 | 4 |
|
5 | 5 | test("should return 11 for Ace of Spades", () => { |
6 | | - const aceofSpades = getCardValue("A♠"); |
7 | | - expect(aceofSpades).toEqual(11); |
| 6 | + const aceOfSpades = getCardValue("A♠"); |
| 7 | + expect(aceOfSpades).toEqual(11); |
8 | 8 | }); |
9 | 9 |
|
10 | 10 | // Case 2: Handle Number Cards (2-10): |
| 11 | +test("should return 5 for Five of Hearts", () => { |
| 12 | + const fiveOfHearts = getCardValue("5♥"); |
| 13 | + expect(fiveOfHearts).toEqual(5); |
| 14 | +}); |
| 15 | + |
| 16 | +test("should return 10 for Ten of Clubs", () => { |
| 17 | + const tenOfClubs = getCardValue("10♣"); |
| 18 | + expect(tenOfClubs).toEqual(10); |
| 19 | +}); |
11 | 20 | // Case 3: Handle Face Cards (J, Q, K): |
| 21 | +test("should return 10 for Jack of Diamonds", () => { |
| 22 | + const jackOfDiamonds = getCardValue("J♦"); |
| 23 | + expect(jackOfDiamonds).toEqual(10); |
| 24 | +}); |
| 25 | + |
| 26 | +test("should return 10 for Queen of Hearts", () => { |
| 27 | + const queenOfHearts = getCardValue("Q♥"); |
| 28 | + expect(queenOfHearts).toEqual(10); |
| 29 | +}); |
| 30 | + |
| 31 | +test("should return 10 for King of Spades", () => { |
| 32 | + const kingOfSpades = getCardValue("K♠"); |
| 33 | + expect(kingOfSpades).toEqual(10); |
| 34 | +}); |
12 | 35 | // Case 4: Handle Ace (A): |
| 36 | +test("should return 11 for Ace of Clubs", () => { |
| 37 | + const aceOfClubs = getCardValue("A♣"); |
| 38 | + expect(aceOfClubs).toEqual(11); |
| 39 | +}); |
13 | 40 | // Case 5: Handle Invalid Cards: |
| 41 | +test("should throw an error for invalid card rank", () => { |
| 42 | + expect(() => getCardValue("Z♠")).toThrow("Invalid card rank"); |
| 43 | +}); |
0 commit comments