-
Notifications
You must be signed in to change notification settings - Fork 699
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
tests: Complete the test suite for TriesOverview
Component
#11906
Conversation
return this.pastTries.length | ||
? this.pastTries.find(t => t.correct === this.maxQuestionsCorrect).time_spent | ||
: null; |
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.
If the length of pastTries
is not 0
, then we are guaranteed to have a try
object as the result of line 121
as this.maxQuestionsCorrect
would be returning the score of the same (and thus we would always find it).
If not, then we can return the same as null
.
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.
@EshaanAgg sorry, I just noticed that If, for some reason, there is a corrupted object, and a try.correct
is undefined
, then Math.max
will give NaN
, and the .find
will be null. It is better to add the null check, as before, in case anything can happen with the tries objects.
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.
Okay sir, got that! Will revert these changes.
Build Artifacts
|
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.
Overall it looks pretty good! Just a small consideration
}); | ||
|
||
test('renders the best score as 0 when there are no past tries', () => { | ||
renderComponent(); |
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 can pass the pastTries
explicitly as an empty array and the totalQuestions
value.
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.
Got it! Thanks for the review!
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.
It seems that we forgot to update the code here 😅 I meant to add something like:
renderComponent({ pastTries: [] });
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.
My bad! I totally missed this comment. Will update.
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.
Thank you!
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.
LGTM! Thanks @EshaanAgg!
Summary
TriesOverview
Component withVTL
null
values.I might be misunderstanding some functionality or missing out on some edge cases, so a second set of eyes would be helpful!
References
Parent Issue
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)