|
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 2 for 2 of hearts", () => { |
| 12 | + const twoOfHearts = getCardValue("2♥"); |
| 13 | + expect(twoOfHearts).toEqual(2) |
| 14 | +}) |
| 15 | + |
| 16 | +test("should return 10 for 10 of Diamonds", () => { |
| 17 | + const tenOfDiamonds = getCardValue("10♦"); |
| 18 | + expect(tenOfDiamonds).toEqual(10) |
| 19 | +}); |
| 20 | + |
11 | 21 | // Case 3: Handle Face Cards (J, Q, K): |
| 22 | + |
| 23 | +test("should return 10 for Jack of Clubs", () => { |
| 24 | + const jackOfClubs = getCardValue("J♣"); |
| 25 | + expect(jackOfClubs).toEqual(10) |
| 26 | +}); |
| 27 | + |
| 28 | +test("should return 10 for Queen of Hearts", () => { |
| 29 | + const queenOfHearts = getCardValue("Q♥"); |
| 30 | + expect(queenOfHearts).toEqual(10) |
| 31 | +}); |
| 32 | + |
| 33 | +test("should return 10 for King of Spades", () => { |
| 34 | + const kingOfSpades= getCardValue("K♠"); |
| 35 | + expect(kingOfSpades).toEqual(10) |
| 36 | +}); |
| 37 | + |
12 | 38 | // Case 4: Handle Ace (A): |
| 39 | +test("should return 11 for Ace of Spades", () => { |
| 40 | + const aceOfHearts = getCardValue("A♥"); |
| 41 | + expect(aceOfHearts).toEqual(11); |
| 42 | +}); |
| 43 | + |
13 | 44 | // Case 5: Handle Invalid Cards: |
| 45 | + |
| 46 | +test("should throw an error for invalid card", () => { |
| 47 | + expect(() => getCardValue("1♣")).toThrow("invalid card rank."); |
| 48 | +}); |
0 commit comments