Below is the component I need to test. Sorry, its seems simple, but I'm new to React and Javascript.
import React from 'react';
export default ({ comments }) => {
const renderedComments = comments.map(comment => {
let content;
if (comment.status === 'approved') {
content = comment.content;
}
if (comment.status === 'pending') {
content = 'This comment is awaiting moderation';
}
if (comment.status === 'rejected') {
content = 'This comment has been rejected';
}
return <li key={comment.id}>{content}</li>;
});
return <div><h4>Reviewer Comments</h4><ul>{renderedComments}</ul></div>;
};
Aucun commentaire:
Enregistrer un commentaire