West Midlands | 26-Jan-ITP | Fida H Ali Zada | Sprint 3 | Implement and Rewrite Tests#1129
Conversation
| // https://jestjs.io/docs/expect#tothrowerror | ||
|
|
||
| // Number Cards (2-10) | ||
| test(`should return the number (numeric value)`, () => { |
There was a problem hiding this comment.
How about ... the numeric value of number cards?
| test(`should return true when (numerator < denominator)`, () => { | ||
| expect(isProperFraction(0, 1)).toEqual(true); | ||
| }) | ||
|
|
||
| test(`should return true when (numerator < denominator)`, () => { | ||
| expect(isProperFraction(-6, -3)).toEqual(true); | ||
| }) | ||
|
|
||
| test(`should return true when (numerator < denominator)`, () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| }) | ||
|
|
||
| test(`should return false when (numerator > denominator)`, () => { | ||
| expect(isProperFraction(2, 1)).toEqual(false); | ||
| }) | ||
|
|
||
| test(`should return false when (numerator == denominator)`, () => { | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| }) | ||
|
|
||
| test(`should return false when (numerator > denominator)`, () => { | ||
| expect(isProperFraction(-1, -2)).toEqual(false); | ||
| }) | ||
|
|
||
| test(`should return false when (numerator > denominator)`, () => { | ||
| expect(isProperFraction(0, -1)).toEqual(false); | ||
| }) No newline at end of file |
There was a problem hiding this comment.
Since you have updated the function, can you also update this test script?
You can use notations such as | ... | or abs( ... ) in the test description, and can probably group some of the test cases into the same group.
There was a problem hiding this comment.
Ah, got it, sir! I totally forgot the test cases. Now I fixed them.
| test(`should return false when (numerator == denominator)`, () => { | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| }) No newline at end of file |
There was a problem hiding this comment.
This test would have missed detecting a bug in this implementation:
function isProperFraction(numarator, denominator) {
if (denominator == 0) return false;
return Math.abs(numarator) <= Math.abs(denominator);
}| expect(isProperFraction(2, 1)).toEqual(false); | ||
| expect(isProperFraction(-2, -1)).toEqual(false); | ||
| }) | ||
|
|
There was a problem hiding this comment.
You have more comprehensive test data in Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js.
|
Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it. |
Learners, PR Template
Self checklist
Changelist
Completed the Sprint 3 Implement and Rewrite Tests. I hope to see comments on my work so I can improve. Thank you.