-
-
Notifications
You must be signed in to change notification settings - Fork 283
Glasgow | 25-ITP-SEP | Mohammed Abdoon | Sprint 3 | Coursework/1-implement-and-rewrite-tests #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
aa5dc2a
a805d98
4b4d8da
ba6d069
79156df
049c628
6cd7b35
d489ca1
123c3c2
7a3bb54
4e2d6be
7e35093
f8f268c
35475f7
76a034c
effa3b4
8237ab8
2214586
8e2e5eb
37aedba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| node_modules | ||
| .DS_Store | ||
| .vscode | ||
| testing.js | ||
| **/.DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,28 @@ test("should return 11 for Ace of Spades", () => { | |
| }); | ||
|
|
||
| // Case 2: Handle Number Cards (2-10): | ||
| test("should return the number entered as input", () => { | ||
| for (let i = 2; i <= 10; i++) { | ||
| expect(getCardValue(`${i}♠`)).toEqual(i); | ||
| } | ||
| }); | ||
|
|
||
|
Comment on lines
11
to
16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples. For example, one possible category for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I changed the code and added more test cases + added different statements using for loop to test numbers from 2 to 10 |
||
| // Case 3: Handle Face Cards (J, Q, K): | ||
| test("should return 10 for face cards J Q K", () => { | ||
| expect(getCardValue("Q♠")).toEqual(10); | ||
| expect(getCardValue("J♠")).toEqual(10); | ||
| expect(getCardValue("K♠")).toEqual(10); | ||
| }); | ||
|
|
||
| // Case 4: Handle Ace (A): | ||
| test("should return 11 when entering Ace A", () => { | ||
| expect(getCardValue("A♠")).toEqual(11); | ||
| }); | ||
|
|
||
| // Case 5: Handle Invalid Cards: | ||
| test(`should return string ("Invalid card rank.") for invalid inputs`, () => { | ||
| expect(getCardValue("HelloWorld!")).toEqual("Invalid card rank."); | ||
| expect(getCardValue("♠")).toEqual("Invalid card rank."); | ||
| expect(getCardValue("979")).toEqual("Invalid card rank."); | ||
| expect(getCardValue("1")).toEqual("Invalid card rank."); | ||
| }); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could specify multiple
expect(...)statements within eachtest()to cover multiple values that belong to the same case. For example,