getString(comment) {
const authorName = comment.getAuthor().getName();
if (!comment.getRepliedTo()) return authorName;
return `${comment.getMessage()} by ${authorName} (replied to
${this.getString(comment.getRepliedTo())})`;
}
toString() {
const authorName = this.getAuthor().getName();
if (!this.getRepliedTo()) {
return `${this.message} by ${authorName}`;
}
return this.getString(this);
}
}
同时,这段代码给了我一个错误(隐藏的单元测试)。 到底是什么问题?
应处理toString toString方法应返回正确的层次结构(无回复)