I\'m working on a test and a lot of unit(hidden) tests were given , however I ran into this error with a block of my code. Can you all please help me out?
getStr
I guess your test fails because you mix template literals and string concatenation, if you take e.g.:
`${this._message} + "by" ${authorName}`
then a message will be inserted by the template:
`Heureka! + "by" Archimedes`
I guess it should rather be:
`${this._message} by ${authorName}`
Also repliedTo.authorName
should be wrapped in ${...}
Try this... it worked for me
getString(comment) {
const authorName = comment.getAuthor().getName();
if (!comment.getRepliedTo()) return authorName;
return `${comment.getMessage()} by ${authorName} (replied to ${this.getString(comment.getRepliedTo())})`;
}
toString() {
if(!this._repliedTo){
return `${this._message} by ${this._author.getName()}`;
} else {
return `${this._message} by ${this._author.getName()} (replied to ${this._repliedTo.getAuthor().getName()})`
}
}