Skip to content

Commit

Permalink
Fixed postComment/postAnswer parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaydoner committed Dec 14, 2021
1 parent 0313123 commit 13d93ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions frontend/src/Tests/comments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test('Check if correct post request is sent when creating comment', async () =>
global.fetch = jest.fn().mockImplementation(() =>
Promise.resolve({ json: () => Promise.resolve([]) })
)
const json = await CommentAnswerController.postComment(0,0,"berkaydoner","Hello")
const json = await CommentAnswerController.postComment(0,"Hello")
expect(json.content).toBe("Hello")
expect(json.isAnswer).toBe(false)
expect(json.answers).toEqual([])
Expand All @@ -145,7 +145,7 @@ test('Check if correct post request is sent when creating answer', async () => {
global.fetch = jest.fn().mockImplementation(() =>
Promise.resolve({ json: () => Promise.resolve([]) })
)
const json = await CommentAnswerController.postAnswer(0,0,0,"berkaydoner","Hello")
const json = await CommentAnswerController.postAnswer(0,0,"Hello")
expect(json.content).toBe("Hello")
expect(json.isAnswer).toBe(true)
expect(json.answers).toBe(undefined)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Views/Comments/Comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function Comments(props){
};
const handlePostComment = () => {
if (newComment.startsWith("@" + repliedUser + " ") && repliedComment !== null) {
const answer = postAnswer(0, 1, 1, "bdoner", newComment.substring(repliedUser.length + 2));
const answer = postAnswer(0, 1, newComment.substring(repliedUser.length + 2));
let foundComment = false
const handle_return = (d) => {
if(d.comment_id === repliedComment && !foundComment){
Expand All @@ -57,7 +57,7 @@ export default function Comments(props){
//setComments(getCommentsAndAnswersOfEvent(0))

} else {
const comment = postComment(0, 1, "bdoner", newComment);
const comment = postComment(0, newComment);
setTimeout(() => {
setComments(comments.concat(comment))
}, 400)
Expand Down

0 comments on commit 13d93ff

Please sign in to comment.