Skip to content

Commit

Permalink
[Test] #520 - 답변 좋아요 기능 테스트 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yju0808 committed Apr 12, 2024
1 parent 35cc8f9 commit f5195a1
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion HappyAnding/HappyAndingTests/CommunityRepositoryTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FirestoreTests: XCTestCase {
}

private let testPostId = "4B7F5702-EF0C-4C51-95F9-4CDCA499A58B"
private let testAnswerId = "94F96B2B-71AC-4616-95AD-545EF80F65C1"
private let testAnswerId = "E0B83A68-9536-4976-BD64-41DCB21DB304"
private let testCommentId = "C644F4BF-5F32-4F67-B2D8-18F182A1FB2C"


Expand Down Expand Up @@ -226,6 +226,34 @@ class FirestoreTests: XCTestCase {
waitForExpectations(timeout: 5, handler: nil)
}

// 답변에 좋아요를 누르는 함수 테스트
func testLikeAnswer() {
let expectation = self.expectation(description: "likeAnswer")
let answerId = testAnswerId
let userId = "1"

repository.likeAnswer(answerId: answerId, userId: userId) { success in
XCTAssertTrue(success, "Liking an answer should succeed.")
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
}

// 답변에 좋아요를 제거하는 함수 테스트
func testUnlikeAnswer() {
let expectation = self.expectation(description: "unlikeAnswer")
let answerId = testAnswerId
let userId = "1"

repository.unlikeAnswer(answerId: answerId, userId: userId) { success in
XCTAssertTrue(success, "Unliking an answer should succeed.")
expectation.fulfill()
}

waitForExpectations(timeout: 5, handler: nil)
}

//MARK: - 댓글 관련 테스트

// 특정 게시물의 모든 댓글을 가져오는 함수 테스트
Expand Down

0 comments on commit f5195a1

Please sign in to comment.