From f5195a17608a0c65612b416cf64261b48cae1ea9 Mon Sep 17 00:00:00 2001 From: YJU Date: Fri, 12 Apr 2024 10:37:07 +0900 Subject: [PATCH] =?UTF-8?q?[Test]=20#520=20-=20=EB=8B=B5=EB=B3=80=20?= =?UTF-8?q?=EC=A2=8B=EC=95=84=EC=9A=94=20=EA=B8=B0=EB=8A=A5=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommunityRepositoryTest.swift | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/HappyAnding/HappyAndingTests/CommunityRepositoryTest.swift b/HappyAnding/HappyAndingTests/CommunityRepositoryTest.swift index 647b6308..f38c5fd4 100644 --- a/HappyAnding/HappyAndingTests/CommunityRepositoryTest.swift +++ b/HappyAnding/HappyAndingTests/CommunityRepositoryTest.swift @@ -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" @@ -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: - 댓글 관련 테스트 // 특정 게시물의 모든 댓글을 가져오는 함수 테스트